我有两个 NSManagedContext,一个父级和一个子级用于并发。指定如下:
self.managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
self.backgroundContext = [[NSManagedObjectContext alloc] initWithConcurrencyType: NSPrivateQueueConcurrencyType];
self.backgroundContext.parentContext = self.managedObjectContext;
在我的一个视图控制器中,我将此方法称为:
[Stream followingStreamForUser:self.user fromDictionary:dict inManagedObjectContext: [AppController sharedAppController].backgroundContext];
调用此方法会导致以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship '[...]' between objects in different contexts
好像self.user
不在我backgroundContext
的 我想知道是否可以将我的self.user
对象移动到我的对象,backgroundContext
或者是否可以查看我的用户对象何时何地添加到上下文 X。