I'm working on an application based on Core Data. I'm doing a fetch on Item
. I don't want the fetched objects to be fault when returned because I'm sure they will be accessed immediately. Thus, I set the returnsObjectsAsFaults
to be NO
. However, it doesn't work for me.
Below is how I set up my NSFetchedResultsController
.
NSString *cacheName = @"cache";
[NSFetchedResultsController deleteCacheWithName:cacheName];
NSManagedObjectContext *context = APPDELEGATE.managedObjectContext;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:context];
[request setEntity:entity];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateCreated" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[request setFetchBatchSize:20];
[request setReturnsObjectsAsFaults:NO];
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:context sectionNameKeyPath:nil cacheName:cacheName];
[request release];
NSError *error = nil;
BOOL result = [frc performFetch:&error];
if(!result){
NSLog(@"Unresolved core data error");
}
Any ideas?
Update: Actually, all the fetched objects are faults.
<_PFBatchFaultingArray 0x176f2bc0>(
<Item: 0x17613480> (entity: Item; id: 0x18ba3910 <x-coredata://5C2547EC-0420-4ED5-867D-087DEF4998EA/Item/p610> ; data: <fault>),
<Item: 0x18b832e0> (entity: Item; id: 0x176dda50 <x-coredata://5C2547EC-0420-4ED5-867D-087DEF4998EA/Item/p611> ; data: <fault>),
<Item: 0x18b97040> (entity: Item; id: 0x18b5f830 <x-coredata://5C2547EC-0420-4ED5-867D-087DEF4998EA/Item/p612> ; data: <fault>),
<Item: 0x18bd1d40> (entity: Item; id: 0x18bc2f30 <x-coredata://5C2547EC-0420-4ED5-867D-087DEF4998EA/Item/p613> ; data: <fault>),
<Item: 0x18b996c0> (entity: Item; id: 0x18b8f660 <x-coredata://5C2547EC-0420-4ED5-867D-087DEF4998EA/Item/p619> ; data: <fault>)
)