Forward Declarations
suggest changeIt’s possible to declare a protocol name without methods:
@protocol Person;
Use it in your code (a class definition, for example):
@interface World : NSObject
@property (strong, nonatomic) NSArray<id<Person>> *employees;
@end
and later define the protocol’s methods:
@protocol Person
- (NSString *)gender;
- (NSString *)name;
@end
This is useful when you don’t need the protocol’s details until you import the file that defines it. The class header then stays limited to the class itself.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents