Objective c NSManagedObjects数组,立即获取对象

Objective c NSManagedObjects数组,立即获取对象,objective-c,core-data,nsmanagedobject,nsmanagedobjectcontext,Objective C,Core Data,Nsmanagedobject,Nsmanagedobjectcontext,我有一个NSManagedObjectID数组。有没有比在数组中循环并分别获取关联的托管对象更有效的方法?使用以下谓词执行fetchRequest NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self in %@", arrayOfIds]; 完整示例 NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; fetchRequest.entity =

我有一个NSManagedObjectID数组。有没有比在数组中循环并分别获取关联的托管对象更有效的方法?

使用以下谓词执行
fetchRequest

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self in %@", arrayOfIds];
完整示例

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
fetchRequest.entity = myEntityDescription;

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self in %@", arrayOfIds];

fetchRequest.predicate = predicate;
fetchRequest.sortDescriptors = mySortDescriptors;

NSError *error = nil;
NSArray *managedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release]; fetchRequest = nil;

谢谢,这正是我想要的。我不知道您可以将self用作托管对象ID