Sunday 15 March 2015

objective c - Are these points about delegates in IOS correct? Yes or no? -


I've been struggling with representatives for a long time. This is a very difficult concept for me for some reason. I think now I have more knowledge, but I am still away from the faith.

Please tell that none of these is wrong / incomplete and why thanks.

  1. Representative implementation protocol (unchanged method header)

  2. An object (a representative) can register a representative (he Applies a protocol). This prototype can be used by declaring the property of the implementing type ID:

      @property (weak, nanatomic) id & lt; MyProtocol & gt; MyDelegate; Representative   
  3. The representative can call some methods (such as those specified in the MyProtocol protocol)

  4. Any class that applies the protocol And should be representative of the deliitte, can declare himself like this:

      MyDelegator * myDelegator = segue.destinationViewController; MyDelegator Delegate = self;    
  5. The advantage of using a representative:

    a. Coupling reduces (Representatives and reps are not dependent on each other) which is an important OO design principle

    b makes the representative more normal; It can now work with other objects, not just this representative

    < P> 1, 2 - Yes

    3 - Call MyProtocol any way,

    4 - Correct.

    5 - Almost right, a very good description can be found here

No comments:

Post a Comment