iOS|iOS 开发中NSNotification(通知)的使用

注意:注册通知和接收通知的Name必须相同(即notificationWithName:@"buttonLoseResponse"&&addObserver: selector: name:@"buttonLoseResponse")
一.在要发出通知的界面注册通知并发送通知:
1.注册通知:
NSNotification *LoseResponse = [NSNotification notificationWithName:@"buttonLoseResponse" object:nil];
2.发送通知:
[[NSNotificationCenter defaultCenter] postNotification:LoseResponse];
二.要接受通知的界面
1.接收通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(walkVCClick:) name:@"buttonLoseResponse" object:nil];
2.实现方法:
- (void)walkVCClick:(NSNotification *)noti
【iOS|iOS 开发中NSNotification(通知)的使用】{
}
3.移除通知:
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

    推荐阅读