NSPrivateQueueConcurrencyTypeとNSMainQueueConcurrencyTypetypesforを使用する場合NSManagedObjectContext、同じコンテキストでネストされたperformBlock呼び出しを行うのは安全ですか?
[backgroundContext performBlock:^{
   NSFetchRequest *myRequest = ...;  
   __block NSArray *result= nil;
   [backgroundContext performBlockAndWait:^{
       results = [backgroundContext executeFetchRequest:myRequest error:NULL];
   }];
}];
ばかげているように見えるかもしれませんが、executeFetchRequest呼び出しをカプセル化する多くのヘルパーメソッドを備えた既存のコードベースがあります。呼び出し元がすでにperformBlockを使用しているかどうかについて推測したくありません。例えば:
-(void)updateObjects:(BOOL)synchronous
{
    if (YES == synchronous)
        [self fetchHelper];
    else
    {
        [backgroundContext performBlock:^{
             [self fetchHelper];
        }];
    }
}
-(NSArray*)fetchHelper
{
     [self.backgroundContext performBlockAndWait:^{
         //Fetch the objects...
         [self.backgroundContext executeFetchRequest: (...)];
     }];
}
私はそれを試しました、そしてそれは働きます。しかし、私はコアデータとマルチスレッドに非常に注意することを(難しい方法で)学びました。