NSDictionary-无法识别的选择器发送到实例-错误

时间:2018-07-26 23:13:06

标签: nsdictionary

我正在尝试解析从Web服务返回的JSON。响应JSON如下所示: {“ API_Count”:“ 17”}

这是我的代码。仅尝试获取值(17)。关键值。 这是我的代码。“基本”一定是错误的。我收到错误

**[NSTaggedPointerString objectForKey:]: unrecognized selector sent to instance**


***Any ideas??***


NSData *jsonData = [responseObject dataUsingEncoding:NSUTF8StringEncoding];
NSError *err = nil;

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&err];

for (NSDictionary *item  in json )
{
    NSObject *val = [item objectForKey:@"API_Count"];

    // ERROR !!! [NSTaggedPointerString objectForKey:]: unrecognized selector sent to instance 0xa32b4de1b0d02c49


}

1 个答案:

答案 0 :(得分:0)

NSDictionary * json = [NSJSONSerialization JSONObjectWithData:jsonData选项:NSJSONReadingAllowFragments错误:&err];

NSInteger val = [[json objectForKey:@“ API_Count”] intergerValue];