我有NSMutableArray数据如下。
{
Id = "57\n ";
Image = "http://www.mysite.com/32f7aff4-9cb2-4044-a555-bfac8ea6eace.gif\n ";
NameEn = "salim\n ";
SpecializationsEn = "Dentistry\n ";
}
现在我想获得Imaage的名字,因此我尝试了
[[feeds objectAtIndex:0] objectForKey:@"Image"]
但是这给了我错误
-[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x759b0b0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x759b0b0'
知道出了什么问题吗?
答案 0 :(得分:1)
据我所知,您发布的数据结构中没有数组对象,而是字典对象,字典不会响应objectAtIndex:。
尝试替换它:
[[feeds objectAtIndex:0] objectForKey:@"Image"]
有了这个:
[feeds objectForKey:@"Image"]
或者,如果您更喜欢现代的Objective-C语法,那么:
feeds[@"image"];
答案 1 :(得分:0)
如果你使用NSMutableArray,那么你应该写[array valueForKey:@"key"];
来从中检索元素