2013-02-06 25 views
0
{ 
ErrorCodes = ( 
    12 
); 
Success=0; 
} 

我有類似上面的json響應,我想從錯誤代碼中獲取12,以便我可以顯示相應的錯誤消息。我做這樣的從IOS中的json響應中提取錯誤代碼

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

但是這是給像

[__NSArrayM integerValue]: unrecognized selector sent to instance 

什麼我做錯了什麼異常錯誤?以及如何將錯誤代碼12轉換成NSInteger ...

+0

再次一次。解析來自JSON和無法識別的選擇器的數據。 – Sulthan

回答

1

ErrorCodes這裏是一個數組,這就是你得到錯誤的原因。你應該嘗試這樣的代替:

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

哦,是的,你是對的..謝謝 – Shaunak