nsdictionary - 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
}
解决方案
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData 选项:NSJSONReadingAllowFragments 错误:&err];
NSInteger val = [[json objectForKey:@"API_Count"] intergerValue];
推荐阅读
- matplotlib - Matplotlib 子图如何将 ax 从一个子图复制到另一个子图?
- pandas - 如何删除 Pandas DataFrame 中部分重复的行?
- python - AWS EC2 Linux 实例,在更新 bindIp mongod 服务失败后
- if-statement - BI Publisher rtf 模板日期空条件
- typescript - 打字稿联合类型泛型参数
- python-3.x - 在 pandas 数据框中创建一个新列,该列由数据框中每个玩家的前一年统计数据组成
- java - 为什么 JVM 没有在字符串池内存中“看到”重复的字符串值?
- core-bluetooth - 问:CoreBluetooth 外围设备:didConnect 调用了两次
- git - Git通过命令行压缩分支时,如何更新消息的日期
- c# - 从同一解决方案中的不同测试项目引用项目中的 C# 命名空间