iOS--通知的使用(NSNotificationCenter )
来源:互联网 发布:苹果蓝牙共享网络 编辑:程序博客网 时间:2024/06/10 00:52
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:@"exitLogin"object:nil];
//接收通知
[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(NSNotificationExitLogin:) name:@"exitLogin" object:nil];
//移除观察者(为了避免观察者重复创建,占用内存)
- (void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:selfname:@"exitLogin"object:nil];
}
通知 是在跳转控制器之间常用的传值代理方式,除了代理模式,通知更方便、便捷,一个简单的Demo实现通知的跳转传值.
- (IBAction)buttonClick:(id)sender {
}
在发送通知后,在所要接收的控制器中注册通知监听者,将通知发送的信息接收
- (void)viewDidLoad {
}
- (void)tongzhi:(NSNotification *)text{
}
移除通知:removeObserver:和removeObserver:name:object:
其中,removeObserver:是删除通知中心保存的调度表一个观察者的所有入口,而removeObserver:name:object:是删除匹配了通知中心保存的调度表中观察者的一个入口。
这个比较简单,直接调用该方法就行。例如:
[[NSNotificationCenter defaultCenter] removeObserver:observer name:nilobject:self];
注意参数notificationObserver为要删除的观察者,一定不能置为nil。
- iOS--通知的使用(NSNotificationCenter )
- iOS通知NSNotificationCenter的使用
- ios NSNotificationCenter通知的使用
- IOS中通知中心(NSNotificationCenter)的使用
- IOS中通知中心(NSNotificationCenter)的使用
- iOS中通知的使用NSNotificationCenter
- iOS 通知中心(NSNotificationCenter)的使用
- iOS中通知的使用NSNotificationCenter
- iOS开发:NSNotificationCenter,通知中心的使用
- NSNotificationCenter 通知的使用
- NSNotificationCenter 通知的使用
- 快速使用 NSNotificationCenter iOS通知
- iOS使用NSNotificationCenter通知崩溃
- IOS中通知中心(NSNotificationCenter)的使用总结
- IOS中通知中心(NSNotificationCenter)的使用总结
- IOS中通知中心(NSNotificationCenter)的使用总结
- iOS中通知中心(NSNotificationCenter)的使用总结
- iOS-通知中心(NSNotificationCenter)的使用总结
- Android通用流行框架大全
- 利用聚合数据实现天气预报APP
- 基于区块链的价值交易和管理系统
- #if, #elif, #else, #endif 使用
- 聊聊HTTPS和SSL/TLS协议
- iOS--通知的使用(NSNotificationCenter )
- [js]关于闭包与访问数组下标的老生常谈
- 【技术架构】负载均衡算法
- 使用MEAN进行现代化WEB开发
- JAVA 访问MySQL数据库(使用方法及测试)
- 希望在这里学到更多
- [C++ && Python]简单模拟代码评测系统
- select(poll)实现代码实现分析(基于kernel 3.10.0)
- mysql基础使用浅谈(1)