Introduction, Shao
I. Proxy design:
When object A has some behavior and wants to inform object B (let object B become the proxy object of object)
Object B wants to listen to some behaviors of object A (making object B the proxy object of object)
When object A cannot process certain behaviors, let object B be the proxy object of object)
2. Passing values between objects
Steps for using Proxy: first, identify who calls someone else's proxy and who acts as someone else's proxy
Please represent the trilogy:
1> write a protocol and list the tasks that you are not convenient (or do not want to) (@ protocol StudentDelegate <NSObject>)
2> include an object that complies with the protocol. The object can be of any type (id <StudentDelegate> delegate ;)
3> when you want to notify the proxy to do something, it is to call the corresponding method of the proxy.
([Self. delegate studentDidReceiveDelivery: self];)
When someone else's agent trilogy:
1> comply with the Protocol (@ interface Teacher: NSObject <StudentDelegate>)
2> implement the corresponding methods in the Protocol
3> set the proxy object and assign a value to the proxy object. Establish the proxy relationship between the two.