NSFetchRequest
メインスレッドで次のように作成した場合:
NSManagedObject *bar = ...;
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Foo"];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"SELF.bar == %@",
[bar objectID]]];
NSFetchRequest
これをNSPredicate
を含む でNSManagedObjectID
バックグラウンド スレッドに渡しても安全ですか?
NSManagedObject *bar = nil;
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Foo"];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"SELF.bar == %@",
[bar objectID]]];
NSPersistentStoreCoordinator *persistentStoreCoordinator = ...;
[[NSBlockOperation blockOperationWithBlock:^{
NSManagedObjectContext *managedObjectContext = [NSManagedObjectContext new];
[managedObjectContext setPersistentStoreCoordinator:persistentStoreCoordinator];
NSArray *foos = [managedObjectContext executeFetchRequest:fetchRequest
error:NULL];
}] start];