mardi 15 décembre 2015

Multiple classes adopting same protocol

I have a VCCOntroller and potentially n+1 classes

All the classes implements <VCCOntrollerDelegate> and VCCOntroller holds pointer for those classes. when a delegate needs to be chosen VCCOntroller decides which pointer will recieve the delegates call

vcDelegate = classN

VCCOntroller
    //has a delegate for 
    -(void)update;
    -(void)fetch;
    -(void)organize;

    //logic chooses
    vcDelegate = classA or classB or class N
    [vcDelegate fetch];

    needs to get called
    -(void)updateTest:(NSStrin *)text; 

Class A <VCCOntrollerDelegate>
    //fetches stuff 
    //then needs to update VCController's
    [delegate updateTest@"YAY"]; 

Class B <VCCOntrollerDelegate>
    //fetches stuff 
    //then needs to update VCController's
    [delegate updateTest@"YAY"];
.
.
.

Class N <VCCOntrollerDelegate>
    //fetches stuff 
    //then needs to update VCController's
    [delegate updateTest@"YAY"];

Now problem is I want VCController to adopt a protocol VCController<Someprotocol>

This someprotocpl will have the -(void)updateTest:(NSStrin *)text; method and classN will simply call

 [classN updateTest@"YAY"];

How can I achieve this Someprotocol?

Aucun commentaire:

Enregistrer un commentaire