我正在使用这段代码来查询核心数据并返回键的值,我这样存储值:
NSString *newName= @"test";
[newShot setValue:newName forKey:@"shotNumber"];
我这样查询:
NSManagedObject *mo = [items objectAtIndex:0]; // assuming that array is not empty
NSString *value = [[mo valueForKey:@"shotNumber"] stringValue];
NSLog(@"Value : %@",value);
虽然这条消息让我崩溃了:
[NSCFString stringValue]: unrecognized selector sent to instance,
有谁知道那是从哪里来的?
最佳答案
newName
(@"test"
) 已经是一个 NSString。无需调用 -stringValue
将其转换为字符串。
NSString *value = [mo valueForKey:@"shotNumber"];
关于iphone - [NSCFString 字符串值] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3823161/