To summarize:
Delegate is a kind of coordination thought of the Division of labor between the program and the unit.
Protocal this thing can not be said alone, to be related to its two main things together, one is a delegate is usually a view, a delegate is usually a controller
It is mainly used to pre-define a protocol, can be understood as the idea of TCP/IP protocol, the service side, the client is the TCP/IP protocol specification to communicate.
Now that it's called a protocol, it must have a definite definition of what it does, the behavior, or what it is called.
What this so-called doing is predefined, called by the delegate (implemented by the entrusted person), and the definition is defined by defining the name of the action and the corresponding parameter and type.
The following is where the entrusted person follow the protocol and then implements it. The delegate can set his or her principal to be a person, that is, to set the client's reference to his own delegate attribute.
Anycontroller.delegate = self. Self in this class to implement the Protocol method.
If the principal has a specific client, it can effectively invoke the pre-defined method in the protocol.
The delegate also needs to declare the properties of the good one delegate in the header file of the class definition (@PROPERTY id<protoacalname> delegate this form).
That such an organic mechanism of cooperation came out, and these are a clear coordination between the working method is completed.
That is, both the VIEW & CONTROLLER adhere to the Protocal protocol, as if the server and the client follow the implementation of the TCP/IP protocol
//------------------------------------------------------------------------------------------------------------- ----Concolusion
Protocal is used to define expected behavior @protocal {-(void) method_name;} @end
View is used to invoke the behavior defined by Protocal, which is called [View.delegate method_name_defined_in_protoal];
The controller is used to implement the behavior defined by the Protocal, and the controller is set to the delegate of the view. The delegate property that is referenced to the controller is passed. View.delegate = self;
The collaboration between the entire program module functionality is clear, it is not the only good way, but it is a good way.
IOS Delegate & Protocal