从NSDictionary

时间:2015-07-14 14:59:19

标签: json nsarray nsdictionary nsobject

我有下面的数组

(
    (
        "id:19",
        "name:Virgin Club House Heathrow",
        "address:Heathrow Airport, 234 Bath Road, Hayes, Middlesex",
        "postcode:UB3 5AP",
        "latitude:51.48127",
        "longitude:-0.448696"
    ),
        (
        "id:20",
        "name:Le Bilboquet",
        "address:20 E 60th St, New York, United States",
        "postcode:NY 10022",
        "latitude:40.764072",
        "longitude:-73.970834"
    )
)

我通过使用

枚举
[venuesArray enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger index, BOOL *stop)
{
     NSString* tmpStr;
     tmpStr = [obj objectForKey:@"id"];
}];

然而我收到此错误 - [__ NSCFArray objectForKey:]:无法识别的选择器发送到实例0x7ff26866a690。

1 个答案:

答案 0 :(得分:0)

就像你说的,你有一个阵列。即使你的块正在调用它正在获取NSDictionary的对象,它也会被赋予一个数组。使用NSLog打印出obj的数据类型和内容以进行调试。