1.創(chuàng)建通知,通過通知中心發(fā)送通知(比如你在a控制器想讓b控制器做點什么的時候金踪,并且控制器沒什么關(guān)系的情況下)
NSNotification *Notification =[NSNotification notificationWithName:@"tongzhi" object:nil userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotification:Notification];
2.注冊通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tongzhi) name:@"tongzhi" object:nil];
2.1綁定通知實現(xiàn)的方法
- (void)tongzhi{
NSLog(@"-----接收到通知------");
}
3.發(fā)送通知頁面一定要在頁面銷毀是同時銷毀通知
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"tongzhi" object:nil];
}