简体   繁体   中英

Core Data Fault objects

I am using Core Data in my project.

I have faced a problem, when fault object's relations do not unfault after i access them in code.

My question: is it possible, that fault relation can stay fault after accessing to it.

upd:

NSManagedObjectContext *context = self.context;
    
if (!context)
return nil;
    
    NSFetchRequest *request = NSFetchRequest.new;
request.entity = [NSEntityDescription entityForName:name inManagedObjectContext:context]; 
    request.predicate = predicate;
    
    if (sortDescriptors)
        [request setSortDescriptors:sortDescriptors];
        
    return [context executeFetchRequest:request error:nil];

context - is default context on main thread. I access object's relationships on main thread.

Not sure what the problem is/what you want to achieve. If your fetch request returns faults instead of objects, do

request.returnsObjectsAsFaults = NO;

If you also want some properties/relationships of your fetched objects to be fetched as well/not be faults, do

[request setRelationshipKeyPathsForPrefetching:@[@"someProperty1",@"someOtherPropertyInEntity"]];

This last one sometimes helps tremendously when improving performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM