我正在尝试确定导致此错误的原因:
2014-06-08 20:40:44.076 Database[8656:70b] -[__NSArrayI length]: unrecognized selector sent to instance 0x8a44050
这是代码。
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
这是发生错误的断点:NSLog([json allKeys]);
用作输入的 JSON 示例:
{"1":{"key":"1","contentONE":"aaa","contentTWO":"testing"},"2":{"key":"2","contentONE":"bbb","contentTWO":null},"3":{"key":"3","contentONE":"ccc","contentTWO":"testing"}}
最佳答案
[json allKeys]
返回一个 NSArray
,而 NSLog
需要一个格式化字符串。试试这个:
NSLog(@"%@", [json allKeys]);
关于iOS Cocoa NSArrayI 长度] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24112392/