Forward Declarations

suggest change

It’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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents