注意:注冊(cè)通知和接收通知的Name必須相同(即notificationWithName:@"buttonLoseResponse"&&addObserver: selector: name:@"buttonLoseResponse")
一.在要發(fā)出通知的界面注冊(cè)通知并發(fā)送通知:
1.注冊(cè)通知:
NSNotification *LoseResponse = [NSNotification notificationWithName:@"buttonLoseResponse" object:nil];
2.發(fā)送通知:
[[NSNotificationCenter defaultCenter] postNotification:LoseResponse];
二.要接受通知的界面
1.接收通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(walkVCClick:) name:@"buttonLoseResponse" object:nil];
2.實(shí)現(xiàn)方法:
- (void)walkVCClick:(NSNotification *)noti
{
}
3.移除通知:
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}