Can someone tell me the difference between
@property (nonatomic, weak) id delegate;
@property (nonatomic, weak) id delegate;
@property
@property (nonatomic, weak) id delegate;
A property with no specific type or protocol implementation. When calling methods on delegate
, anything goes - the compiler will trust you if it can see that a method exists somewhere and the runtime will check if you were lying.
@property (nonatomic, weak) id < protocol_name > delegate;
A property with no specific type, but which implements a specified protocol. You can only call methods from that protocol (unless you do some casting). Any instance that is set to the property must conform to the protocol (or again, you need some casting).
@property (nonatomic, weak) UIViewController * < protocol_name > delegate;
A property with a specific type (UIViewController
) and which implements a specified protocol. You can only call methods from that protocol and from the UIViewController
class (unless you do some casting). Any instance that is set to the property must conform to the protocol and be a subclass of UIViewController
(or again, you need some casting).