我有奇怪的问题。在ViewController.m
,我在成功保存后发布通知并执行 Segue 到ListViewController
. 在ListViewController.m
中,我设置了观察者viewDidLoad
并声明了处理方法。
问题是调用了处理程序方法但没有执行内部代码!知道为什么吗?
// ViewController.m
if (success) {
[[NSNotificationCenter defaultCenter] postNotificationName:kAHPlistSavedSuccessfully object:self];
[self performSegueWithIdentifier:kAHDetailToListSegue sender:self];
}
// ListViewController.m
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(plistSavedSuccessfully:) name:kAHPlistSavedSuccessfully object:nil];
}
- (void)plistSavedSuccessfully:(NSNotification *)notification
{
NSLog(@"notification %@", notification);
[self someMethod]; // not called !
}