如果代码将委托分配给NSFetchedResultsController
如下:
-(id)initWithFetchedResultsController:(NSFetchedResultsController*)fetchedResultsController
{
self = [super init];
if (self != nil)
{
fetchedResultsController.delegate = self;
_fetchedResultController = fetchedResultsController;
}
return self;
}
该NSFetchedResultsControllerDelegate
方法– controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:
从未被调用过self
:
-(void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
NSLog(@"Delegate method called"); // Never called
}
谓词没有问题,分配了一个谓词,并且直接使用通知工作。