1~NSNotificationCenter(必须先注册,再发送)
注册通知:即要在什么地方接受消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@" mytest" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray];
object:传递的参数
- (void) mytest:(NSNotification*) notification
{
id obj = [notification object];//获取到传递的对象
}
2~移除某个通知
[[NSNotificationCenterdefaultCenter] removeObserver:selfname:UIKeyboardWillShowNotificationobject:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cleanDisk) name:UIApplicationWillTerminateNotification object:nil];//APP运行结束
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgroundCleanDisk) name:UIApplicationDidEnterBackgroundNotification
object:nil];//退到后台