Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Protocol Inheritance

    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 652
    Comment on it

    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.

    @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];
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: