私はこの fetchedResult メソッドを持っています:
- (NSFetchedResultsController *)fetchedResultsController
{
if (__fetchedResultsController != nil) {
return __fetchedResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Cards" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setFetchBatchSize:20];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Cards" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Master"];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return __fetchedResultsController;
}
しかし、私がそれを要求するself.fetchedResultsController.fetchedObjects.count
と、必要以上に 1 つ多くのアイテムが返されます。最初の項目は常にこれです。"<Cards: 0x83e9c50> (entity: Cards; id: 0x83e9c80 <x-coredata:///Cards/t8C371600-7875-468C-A529-C918F0008C384> ; data: {\n cardID = nil;\n favourite = 0;\n imageData = nil;\n})"
しかし、ターミナル経由で sqlite をチェックすると、この項目が存在しないことがわかります。それが何であるかについて何か考えはありますか?