在开发过程中,我们常常会遇到需要在某一个视图中点击按钮,其它视图来响应该事件的情况。这时我们可以使用通知来完成这一过程。
[[NSNotificationCenter defaultCenter] postNotificationName:kReloadHomeCtrlNotification object:nil];
其中kReloadHomeCtrlNotification 一般是在预编译文件中宏定义的
同时要在另外一个地方来接收该通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(myAction) name:kReloadHomeCtrlNotification object:nil];
其中myAction即是在接收到该通知时响应的事件,只需要将name,即kReloadHomeCtrlNotification 与之前发送通知的name相对应,就可以发送接收通知了