to : をNSManagedObjectContext
使用して、レシーバーの (メイン) キュー以外のキューでブロックを実行できることに気付きました。NSMainQueueConcurrencyType
performBlockAndWait
たとえば、次のコードでは、 myが typeで myがtypeの場合、 のキューparentContext
でブロックが実行されます。childContext
parentContext
NSMainQueueConcurrencyType
childContext
NSPrivateQueueConcurrencyType
[childContext performBlockAndWait:^{
//Thread 1, Queue: NSManagedObjectContext Queue
[parentContext performBlockAndWait:^{
//Thread 1, Queue: NSManagedObjectContext Queue
//This is the same queue as the child context's queue
}];
}];
対照的に、次のコードは期待どおりに機能しparentContext
ます。my はメイン キューでブロックを実行します。
[childContext performBlock:^{
[parentContext performBlockAndWait:^{
//Thread 1, Queue: com.apple.main-thread
}];
}];
これは予想される動作ですか?ドキュメントの状態以来、それは確かに私を混乱させています"performBlockAndWait: synchronously performs a given block on the receiver’s queue."