【问题标题】:Extracting error code from json response in IOS从IOS中的json响应中提取错误代码
【发布时间】:2013-02-06 11:52:09
【问题描述】:
{ 
ErrorCodes = ( 
   12 
); 
Success=0; 
}

我有像上面这样的 json 响应,我想从错误代码中获取 12,以便我可以显示适当的错误消息。我就是这样的

NSInteger err = [[dict objectForKey:@"ErrorCodes"] integerValue]; 

但这会产生异常错误

[__NSArrayM integerValue]: unrecognized selector sent to instance

我做错了什么?以及如何将错误代码 12 转换为 NSInteger...

【问题讨论】:

  • 一次又一次。解析来自 JSON 和无法识别的选择器的数据。

标签: ios json nsinteger


【解决方案1】:

ErrorCodes 这里是一个数组,这就是你得到错误的原因。你应该尝试这样的事情:

[[[dict objectForKey:@"ErrorCodes"] objectAtIndex:0] integerValue];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 2023-04-11
    • 1970-01-01
    • 2018-12-29
    相关资源
    最近更新 更多