奇妙な問題があります。でViewController.m
、保存が成功した後に通知を投稿し、Seguetoを実行し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 !
}