0
我在我的應用程序中遇到了一個奇怪的問題。我想要填充我的數組。NSFetchedResultsController在進入後臺後丟失了他的行
它宣稱這種方式(作爲@propoerty (nonatomic, retain)
)
- (NSFetchedResultsController *)fetchedContactsController {
if (self->fetchedContactsController != nil) return self->fetchedContactsController;
// Create the fetch request
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// I want every contact...
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Contact" inManagedObjectContext:self->managedObjectContext];
[fetchRequest setEntity:entity];
// ... whose are not associated with my order item
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (%@ IN items)", self.orderItem];
[fetchRequest setPredicate:predicate];
// Edit the section name key path and cache name if appropriate
self.fetchedContactsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self->managedObjectContext sectionNameKeyPath:nil cacheName:nil];
[aFetchedResultsController release];
[firstnameSortDescriptor release];
[lastnameSortDescriptor release];
[sortDescriptors release];
[fetchRequest release];
// Execute the fetch request
[self->fetchedContactsController performFetch:nil];
return self->fetchedContactsController;
}
當然
,contacts.items存在。
當我的應用程序轉到後臺然後再前景,如果我做的是另
每一行中我的陣列消失!
編輯:
如果我評論這些行:
// ... whose are not associated with my order item
//NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (%@ IN items)", self.orderItem];
//[fetchRequest setPredicate:predicate];
的問題不要再發生!但這不是我想要的...