我注意到NSManagedObjectContext
可能與NSMainQueueConcurrencyType
到performBlockAndWait
:並且在接收者(主)隊列以外的隊列上執行該塊。NSManagedObjectContext的performBlockAndWait:不在接收者的隊列上執行
例如,下面的代碼的結果在我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
主隊列執行程序塊:
[childContext performBlock:^{
[parentContext performBlockAndWait:^{
//Thread 1, Queue: com.apple.main-thread
}];
}];
這是對EXP行爲?自從文檔狀態
您如何檢查代碼的運行隊列? –