转换包含数字的NSString时遇到问题不会转换为整数

时间:2010-12-17 00:14:45

标签: objective-c nsstring int

我有以下代码行:

NSString *dMidiInfo = [object valueForKey:@"midiInformation"];

从调试器返回:

{type = immutable,count = 1,capacity = 3,pairs =(     3:{contents =“192”}

来自此日志语句NSLog(@"this is the string: %@",dMidiInfo);

我明白了: {(     192 )}

但是当这一行执行时:

firstByteB = [dMidiInfo intValue];

我收到此错误:

[NSCFSet intValue]:无法识别的选择器发送到实例0x176f10

括号是否会弄乱我的代码?

经过一些额外的故障排除: 此代码实际上使用此代码的获取请求:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Effect" inManagedObjectContext:context];
[request setEntity:entity];
NSError *error;
NSMutableArray *mutableFetchResults = [[context executeFetchRequest:request error:&error] mutableCopy];

这返回了所有实体,我试图返回一个实体,所以我切换到了这个:

NSArray * currentSelSong = [sillySongs selectedObjects];     NSMutableArray * mutableFetchResults = [currentSelSong valueForKey:@“songToEffect”];

似乎selectedObjects添加括号

1 个答案:

答案 0 :(得分:2)

我认为object的{​​{1}}属性实际上是midiInformation个实例,而不是NSSet