I\'ve seen usage of Objective-C protocols get used in a fashion such as the following:
@protocol MyProtocol
@required
@property (readonly)
Take a look at my article PROPERTY IN PROTOCOL
Suppose I have MyProtocol that declares a name property, and MyClass that conforms to this protocol
Things worth noted
I can’t redeclare this name property, as it already declared by the protocol. Do this will yell an error
@interface MyClass () // Class extension
@property (nonatomic, strong) NSString *name;
@end
How to use property in protocol
So to use MyClass with that name property, we have to do either
Declare the property again (AppDelegate.h does this way)
@interface MyClass : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *identifier;
@end
Synthesize ourself
@implementation MyClass
@synthesize name;
@end