NSNotificationCenter消息通信机制介绍(KVO)
2014-11-15 13:39
323 查看
作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的. 注册通知:即要在什么地方接受消息 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@" mytest" object:nil]; 参数介绍: addObserver: 观察者,即在什么地方接收通知; selector: 收到通知后调用何种方法; name: 通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。 发送通知:调用观察者处的方法。 [[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray]; 参数介绍: postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。 object:传递的参数 注册方法的写法: - (void) mytest:(NSNotification*) notification { id obj = [notification object];//获取到传递的对象 NSLog(@"obj = %@",obj); }
|
相关文章推荐
- NSNotificationCenter消息通信机制介绍(KVO)(转)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- [IOS]NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- IOS学习笔记4-NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制 + KVO
- IOS NSNotificationCenter消息通信机制介绍
- Unity3D开发和总结:用C#封装类似苹果NSNotificationCenter消息通信机制(KVO)
- NSNotificationCenter消息通信机制介绍
- IOS NSNotificationCenter消息通信机制介绍
- IOS学习之 NSNotificationCenter消息通信机制介绍
- Android的消息机制,用Android线程间通信的Message机制,Android中Handler的使用方法——在子线程中更新界面,handler机制