1. Delegate
In the cycle of running a cocoa touch class object, a point in time it will invoke some specified function of the specified class to accomplish what he wants to accomplish. This "specified class" is referred to as the delegate class for this class. The "Specify function" is a method that is defined in the Protocol (protocal).
For example, UITableView, in its operating cycle, invokes a series of functions of the delegate class to do its own initialization work. All we need to do is to specify its delegate class and implement the delegate method that UITableView will invoke in the delegate class. So how do I know what methods UITableView want to invoke? In fact, it is very simple, it is to invoke the method is defined in the Protocol class inside. As you can find in the documentation, the name of the Protocol class associated with UITableView is also prefaced with UITableView. The method defined here is a number of methods that UITableView to invoke during the run cycle.
2. Target
Classes that inherit from Uicontrol, such as UIButton, can set the selector function to invoke the target object when an event is triggered.
[UIButton addTarget: target object name action: function name forControlEvents: event Name]
3. Notification
This allows an object to send messages to the message center, which may be marked with some state information. Other objects may listen to information in the Message center with certain status messages, thereby making the corresponding.
Nsnotification *ntf = [nsnotification notificationwithname:@"Chgvalue" Object: Self]; //declares a message with the name Chgvalue and the sender the object itself. Nsnotificationcenter *ntfcenter =[Nsnotificationcenter Defaultcenter]; [Ntfcenter postnotification:ntf]; //get a singleton in the message center and send a well-defined message to the message center. Nsnotificationcenter *ntfcenter =[Nsnotificationcenter Defaultcenter]; [Ntfcenter addobserver:self selector: @selector (getntf) Name:@"Chgvalue" Object: Self]; [Ntfcenter addobserver:self selector: @selector (GETNTF2) Name:@"Chgvalue" Object: Self]; //get a singleton of the message Center, which is the source of this object, and the message named Chgvalue is distributed to the getntf and GETNTF2 functions of this object.
Cocoa Touch's 3 kinds of communication mode delegate/target/notification