iOS上的可转换属性

时间:2016-09-28 05:17:23

标签: ios objective-c nsdictionary

  

我已将字典存储在transformable属性中。我想知道

如何从中获取单个数据?**

NSFetchRequest  *fetchRequest = [[NSFetchRequest alloc] 
initWithEntityName:@"MemberProfile"];
NSSortDescriptor *ordering = [[NSSortDescriptor alloc] initWithKey:
[member.member_Profile objectForKey:"@order"] ascending:YES];
[fetchRequest setSortDescriptors:[NSArray 
 arrayWithObjects:ordering,nil]];
NSArray *result = [self.managedObjectContext 
executeFetchRequest:fetchRequest error:Nil];
self.masterList = [[NSMutableArray alloc] initWithArray:result];

1 个答案:

答案 0 :(得分:0)

导入NSManagedObject(InstallProject)并获取一个这样的对象,

-(InstallProject *)readSelectedInstall:(NSString *)projIDString
{
NSArray *fetchedObjects;
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
NSEntityDescription *entityDescription = [NSEntityDescription  entityForName:@"InstallProject"  inManagedObjectContext: context];
[fetch setEntity:entityDescription];
[fetch setPredicate:[NSPredicate predicateWithFormat:@"(ANY ProjID contains[cd] %@)",projIDString]];
NSError * error = nil;
fetchedObjects = [context executeFetchRequest:fetch error:&error];

if([fetchedObjects count] == 1)
return [fetchedObjects objectAtIndex:0];
else
return nil;  
}