我刚刚获取数据,但是当我尝试从 NSData 将其附加到字符串时,编译器发生异常错误。我的代码看起来像这样:
NSDictionary *allDAtaDictionary = [NSJSONSerialization JSONObjectWithData:_webData options:0 error:nil];
NSString *jSonStatus = [allDAtaDictionary objectForKey:@"status"];
if([jSonStatus isEqualToString:@"OK"])
{
NSDictionary *results = [allDAtaDictionary objectForKey:@"user_details"];
NSLog(@"User Details : %@",results);
在这些行刚刚开始之前,一切都运行良好:
NSString *userID = [results objectForKey:@"userID"];
错误输出是:
*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x9485a00”
这是我的 jSOn 输出, NSLog(@"User Details : %@",results);
User Details : (
{
userCity = California;
userCountry = "United States";
userDOB = "1988-03-02";
userDetails = "";
userEmail = "xxx@xxx.com";
userFBID = 715296184;
userFullName = "John Mc Grager";
userGender = Male;
userID = 70;
userLastLoginTime = "2013-05-29 10:51:27";
userLatitude = "37.7858";
userLongtitude = "-122.406";
userNickName = warblader;
userPassword = "";
userStatus = 1;
userToken = "";
}
)