IOS开发笔记-消息通信机制NSNotificationCenter
来源:互联网 发布:淘宝跳失率怎么计算 编辑:程序博客网 时间:2024/06/05 14:12
NSNotificationCenter是专门供程序中不同类间的消息通信而设置的,使用起来极为方便,
我仅对以上参数做以说明:addObserver 这个是观察者,就是说 在什么地方接收通知;
我仅对以上参数做以说明:
postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object:传递的参数
发送通知时,默认调用test方法。
设置通知,就是说要在什么地方(哪个类)接受通知,一般在初始化中做。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(test:) name:@" test" object:nil];
我仅对以上参数做以说明:addObserver 这个是观察者,就是说 在什么地方接收通知;
selector 这个是收到通知后,调用何种方法;
name: 这个是通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
发送通知,就是说此时要调用观察者处的方法。
[[NSNotificationCenter defaultCenter] postNotificationName:@"test" object:searchFriendArray];
我仅对以上参数做以说明:
postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object:传递的参数
发送通知时,默认调用test方法。
- (void) test:(NSNotification*) notification{searchFriendArrary = [notification object];//通过这个获取到传递的对象}
0 0
- IOS开发笔记-消息通信机制NSNotificationCenter
- [IOS开发] NSNotificationCenter消息通信机制
- 【IOS】消息通信机制NSNotificationCenter
- ios NSNotificationCenter消息通信机制
- IOS学习笔记4-NSNotificationCenter消息通信机制介绍(KVO)
- iphone ios 消息通信机制NSNotificationCenter
- IOS NSNotificationCenter消息通信机制介绍
- iphone ios 消息通信机制NSNotificationCenter
- IOS NSNotificationCenter消息通信机制介绍
- [IOS]NSNotificationCenter消息通信机制介绍(KVO)
- [iPhone开发]消息通信机制NSNotificationCenter
- [iPhone开发]消息通信机制NSNotificationCenter
- iPhone开发之消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- Javascript中eval方法的应用及其问题。
- error:2014_03_20周四工作日志:string类使用错误。
- 设计模式学习之——六大设计原则之二:里氏替换原则
- Asp.net MVC+unity简单架构
- 中断子系统( 1)初始化
- IOS开发笔记-消息通信机制NSNotificationCenter
- Foundation框架 NSString
- 简单粗暴说ERP
- resin使用
- Editor------------------CustomEditor
- 2014 不算技术博客吧
- AngularJS 的 ngSwitch 指令 (directive) 使用陷阱
- 【Android】ADB常用指令与logcat日志
- string 和string& 做形参时的不同