任何想法为什么这不起作用,我的项目总是错误。
NSManagedObjectContext *tmpContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
tmpContext.parentContext = self.managedObjectContext;
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Bag"];
request.returnsObjectsAsFaults = NO;
request.relationshipKeyPathsForPrefetching = @[@"items"];
NSArray *bags = [tmpContext executeFetchRequest:request error:nil];
Bag *bag = (Bag *)[bags firstObject];
NSLog(@"%@", bag.items);
我得到......
Relationship 'items' fault on managed object (0x79e90e00)
如果我查看CoreData查询,则其中没有JOIN。
SELECT t0.Z_ENT, t0.Z_PK, t0.Z_OPT, .... FROM ZBAG t0 WHERE t0.Z_ENT = ?