Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Objective-C
- @protocol Entity<Validatable>
- - (BOOL)isValid;
- @end
- @interface EntityList<__covariant ObjectType: id<Entity>> {
- Entity* owner;
- NSMutableArray<ObjectType>* list;
- }
- - (instancetype)initWithOwner:(id<Entity>)anOwner;
- - (ObjectType)objectAtIndex:(NSUInteger)index;
- - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
- - (ObjectType)objectForKeyedSubscript:(id <NSCopying>)key;
- - (BOOL)containsObject:(ObjectType)anObject;
- - (void)addObject:(ObjectType)anObject;
- - (NSUInteger)count;
- @end
- @interface Item : Entity {
- }
- @end
- @interface ItemList: EntityList {
- }
- @end
- //Swift
- let list = ItemList(owner: Item())
- 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