One , the agent design mode of the occasion:
When object A has some behavior, you want to tell object B (to make object b a proxy object)
Object B wants to listen to some behavior of object A (Make object b a proxy object)
When object A cannot handle certain behaviors, it wants object B to handle it (making object B a proxy object)
Second , the value of the transfer between the objects
To use a proxy: First of all, be clear about who is the agent, who will act as someone else
Please represent the trilogy:
1> write a protocol that lists things that are inconvenient (or do not want to) (@protocol studentdelegate <NSObject>)
2> contains an object that complies with the agreement, and the object can be any type (id<studentdelegate> delegate;)
3> when you have something to tell the agent to do, is to call the agent corresponding method
([Self.delegate studentdidreceivedelivery:self];)
When someone else's acting trilogy:
1> Compliance Agreement (@interface teacher:nsobject<studentdelegate>)
2> implementation of the protocol inside the corresponding method
3> sets the proxy object and assigns a value to the proxy object. Establishing the agency relationship between the two
Introduction-Agent Mode in OC