我已经从我的应用程序的核心数据中获取了一个结果,并且需要获取我赋予其“容量”属性的整数值。从CoreData获取整数?
'容量'属性是我的核心数据模型中的NSInteger 16。
我得到我的结果,像这样:
entity = [NSEntityDescription entityForName:@"TableInfo" inManagedObjectContext:appDelegate.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"name == %@", [NSString stringWithFormat:@"%@", [tablesArray objectAtIndex:row]]]];
NSArray *selectedTableFetched = [appDelegate.managedObjectContext executeFetchRequest:fetchRequest error:&error];
现在我的问题是我如何才能从我的结果,“能力”的价值?我知道有,因为我有检查数组的计数结果,我已经试过这样:
NSNumber *n = [selectedTableFetched valueForKey:@"capacity"];
它给我的东西,在访问的NSNumber时,我得到一个毫无意义的长号码,因此,如果我尝试访问整数值,像这样:
[n integerValue]
崩溃的应用程序,我得到这个错误:
'NSInvalidArgumentException', reason: '-[__NSArrayI integerValue]: unrecognized selector sent to instance 0x138870'
希望你能帮助我,我需要做的是从容量attribu获取整数值泰,谢谢。
我认为'[selectedTableFetched valueForKey:@ “能力”]'不返回'NSNumber'而是'NSArray' – tipycalFlow 2012-03-25 18:11:05