2 つの NSManagedContext があり、1 つの親と 1 つの子が同時実行に使用されます。次のように指定します。
self.managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
self.backgroundContext = [[NSManagedObjectContext alloc] initWithConcurrencyType: NSPrivateQueueConcurrencyType];
self.backgroundContext.parentContext = self.managedObjectContext;
ビュー コントローラーの 1 つで、このメソッドを呼び出します。
[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 に追加されるかを確認 できるかどうか疑問に思います。