Summary of common protocol features

Can the Objective-C protocol be shared?

Following this tutorial , I'm basically looking for something like this:

@protocol ItemsStore<__covariant ObjectType> <NSObject> -(NSArray <ObjectType> *)items; @end 

What is the general protocol for some ObjectType that "implements" ("inherits") another NSObject protocol

+7
generics objective-c objective-c-protocol
source share
2 answers

As @rmaddy suggested, and as indicated in these questions , this is NOT possible. Shame, moving on to Swift then ...

+2
source share

Perhaps you could just override it as generic in the interface.

 @protocol ItemsStore <NSObject> - (NSArray *)items; @end @interface MyItemsStore<ObjectType> : NSObject <ItemsStore> - (NSArray <ObjectType> *)items; @end 

This seems like an unlikely scenario. You might be better off defining the type of elements in each subclass. Like what Apple does with NSFetchRequest in generating its core data model.

0
source share

All Articles