IOS之NSNotification

NSNotificationCenter是专门供程序中不同类间的消息通信而设置的.

注册通知:

[[NSNotificationCenter defaultCenter]  addObserver:self selector:@selector(mytest:) name:@"mytest" object:nil]; 

参数介绍:

          addObserver: 观察者,即在什么地方接收通知;

        selector: 收到通知后调用何种方法;

        name: 通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。

 发送通知:

[[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray];
原文地址:https://www.cnblogs.com/sfce/p/4318887.html