[hoge controllerDidChangeContent:]: unrecognized selector sent to instance
この現象が発生した場合、fetchedResultsControllerが壊れている可能性がある。
別のViewControllerでCoreDataを使っている場合、Viewを切り替えたときに内容が上書きあるいは破壊されている可能性がある。
この場合、双方のViewControllerについて、viewWillDisappearで、self.fetchedResultsControllerにnilをセットする処理を記述し、viewWillAppearでself.fetchedResultsControllerを再設定する処理を記述する。
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.fetchedResultsController = nil;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
■参考記事
http://stackoverflow.com/questions/1375344/why-is-this-core-data-example-crashing