您的位置:首页 > 其它

NSNotificationCenter发送通知

2014-05-25 17:26 169 查看
在开发过程中,我们常常会遇到需要在某一个视图中点击按钮,其它视图来响应该事件的情况。这时我们可以使用通知来完成这一过程。

[[NSNotificationCenter defaultCenter] postNotificationName:kReloadHomeCtrlNotification object:nil];

其中kReloadHomeCtrlNotification 一般是在预编译文件中宏定义的

同时要在另外一个地方来接收该通知

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(myAction) name:kReloadHomeCtrlNotification object:nil];

其中myAction即是在接收到该通知时响应的事件,只需要将name,即kReloadHomeCtrlNotification 与之前发送通知的name相对应,就可以发送接收通知了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐