Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. //Objective-C
  2.  
  3. @protocol Entity<Validatable>
  4. - (BOOL)isValid;
  5. @end
  6.  
  7. @interface EntityList<__covariant ObjectType: id<Entity>> {
  8. Entity* owner;
  9. NSMutableArray<ObjectType>* list;
  10. }
  11.  
  12. - (instancetype)initWithOwner:(id<Entity>)anOwner;
  13. - (ObjectType)objectAtIndex:(NSUInteger)index;
  14. - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
  15. - (ObjectType)objectForKeyedSubscript:(id <NSCopying>)key;
  16. - (BOOL)containsObject:(ObjectType)anObject;
  17. - (void)addObject:(ObjectType)anObject;
  18. - (NSUInteger)count;
  19.  
  20. @end
  21.  
  22. @interface Item : Entity {
  23. }
  24. @end
  25.  
  26. @interface ItemList: EntityList {
  27.  
  28. }
  29. @end
  30.  
  31.  
  32. //Swift
  33.  
  34. let list = ItemList(owner: Item())
  35. let items = list?.count() //'EntityProtocol' cannot be used as a type conforming to protocol 'EntityProtocol' because 'EntityProtocol' has static requirements
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement