NSFetchRequest setReturnsObjectsAsFaults: not working

I am working on an application based on Core Data. I am fetching on Item . I do not want the returned objects to be caused by an error during the return, because I am sure that they will be available immediately. So I set returnsObjectsAsFaults as NO . However, this does not work for me.

The following shows how I configured 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: in fact, all the extracted objects are errors.

 <_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>) ) 
+8
objective-c core-data fault
source share
2 answers

https://github.com/scottcarter/CoreDataFaultingBug . This may be the answer to my question.

+1
source share

I noticed that too. In my case, I got results in a child context. When I changed the selection in the main context, then returnsObjectsAsFaults behaved correctly.

Again, if I made a selection from the child context, returnsObjectsAsFaults did not work properly.

Someone had a similar problem for the same reason: stack overflow

0
source share

All Articles