通知を使用して、アプリの詳細ビューコントローラーからrootviewコントローラーにデータを渡します。これらのメソッドは、メモリの警告が表示されるまで正常に機能します。
通知は、メモリ警告の後に2回処理されます。
ユーザーがDetailViewControllerで行を選択すると、データをrootviewcontrollerに戻します。didSelectRowAtIndexPathメソッドは1回だけ呼び出されますが、通知オブザーバーは2回呼び出されます。
didReceiveMemoryWarningで通知を削除する必要がありますか?または、コードに他の問題がありますか?
関連するコードを投稿する
RootViewControllerのviewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rowSelected:) name:@"SelectionNotification" object:nil];
DetailViewControllerのdidSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease];
[dictionary setObject:selectedRow forKey:@"row"];
[[NSNotificationCenter defaultCenter] postNotificationName:kSelectionNotificationName object:self userInfo:dictionary];
[[self navigationController] popToRootViewControllerAnimated:YES];
}
助けてくれてありがとう。