通知仅在observer_ViewController
处于活动状态时调用该函数
AppDelegate.m
[[NSNotificationCenter defaultCenter] postNotificationName:kNewShipNotifaction object:ship];
observer_ViewController.m
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newShipCome:) name:kNewShipNotifaction object:nil];
}
- (void)newShipCome:(NSNotification *)notifacation{
[self updateNotifyWithShip:notifacation.object];
}
当我在另一个viewController中时,通知没有调用newShipCome:(NSNotification *)notification
方法。当我切换到observer_ViewController
时,该方法仍然没有被调用。
那么......当我不在observer_ViewController
时,如何才能正确通知更新?
答案 0 :(得分:0)
删除取消注册代码表单viewWillDisappear它将起作用