Like classes and controllers, protocols itself can also be extended and can be used to produce new protocols.
Here we are creating a base Protocol with superset methods.
We can also call it original protocol. it is inherited from NSObject, like other classes in C.
We can also call it original protocol. it is inherited from NSObject, like other classes in C.
- @protocol BaseProtocolDelegate <NSObject>
- - (void)testProtocol;
- @end
- @interface BaseViewController : UIViewController
Here we are creating a child Protocol inheriting Base protocol
- @protocol ChildProtocol <BaseProtocolDelegate>
- - (void)testChildProtocol;
- @end
- @interface FirstViewController : BaseViewController
- @property (nonatomic, retain)id <ChildProtocol> childProtocol;
we can call/use methods of protocols like:
- [childProtocol testProtocol];
For
such more Blogs you can visit to http://findnerd.com/NerdDigest
No comments:
Post a Comment