This type of program needs to be used recently. After studying it, we will share the results with you.
Nsicationicationcenter is specially set for message communication between different classes in the program, which is extremely convenient to use,
Long story short.
Set the notification, that is, where (which class) the notification is to be received, which is generally done during initialization.
[[Nsicationicationcenter defacenter center]Addobserver: Self selector: @ selector (test :)Name: @ "test"Object: Nil];
I will only describe the above parameters: addobserver is the observer, that is, where to receive notifications;
Selector: The method called after receiving the notification;
Name: This is the name of the notification and the unique identifier of the notification. The compiler will find the notification through this.
To send a notification, you must call the method at the observer.
[[Nsicationcenter center defacenter center] postnotificationname: @ "test" Object: searchfriendarray];
I will only describe the above parameters:
Postnotificationname: the name of the notification, which is the unique identifier of the notification. The compiler will find the notification through this.
Object: transmitted Parameters
The test method is called by default when a notification is sent.
-(Void)Test :( nsnotification *) Notification
{
Searchfriendarrary = [Notification object]; // get the passed object through this
}