iOS.Crash.[__NSArrayM objectForKeyedSubscript:]

1. [__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance - source code and screenshot attached

http://stackoverflow.com/questions/21268539/nsarraym-objectforkeyedsubscript-unrecognized-selector-sent-to-instance

2. 关于objectforkeyedsubscript

http://nshipster.com/object-subscripting/

3. NSArray Returning String Instead of Dictionary

http://stackoverflow.com/questions/18782053/nsarray-returning-string-instead-of-dictionary

 

这是由于下面的调用预期返NSDictionary, 然后没有检查返回id 对象的真正类型,而直接

jsonObject[@"key"]; 这样就导致该类的Crash发生。
1 id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:nil];

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。