iOS---NSNotification通知

来源:互联网 发布:ledrom编辑软件 编辑:程序博客网 时间:2024/05/01 13:45

NSNotification线程管理以及自动注销开源方案
http://www.cocoachina.com/ios/20160708/16987.html

NSNotification简单使用:
发送通知

[[NSNotificationCenter defaultCenter]postNotificationName:@"test" object:nil];

接收通知

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

收到通知执行方法test

- (void)test{    //执行处理}

一个通知,可以有很多监听者,只要这些监听者还在生命周期内,都可以响应对应的方法。

0 0
原创粉丝点击