您的位置:首页 > 其它

NSNotificationCenter的使用以及需要注意的问题

2014-10-15 13:55 387 查看
在很多时候我们都需要及时的对响应结果做出处理

通知的使用很简单:

发送通知
[[NSNotificationCenterdefaultCenter]
postNotificationName:@"Success"object:niluserInfo:nil];
接收通知的监听:

[[NSNotificationCenterdefaultCenter]
addObserver:selfselector:@selector(alipaySuccess:)name:@"Success"object:nil];

有时候如果在同一个页面需要发送多次相同的通知,需要在类的析构函数里面移除监听.否则会出现接受多次通知.

[[NSNotificationCenterdefaultCenter]removeObserver:selfname:@"Success"object:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐