I'm trying to pull data from this url, but I am running into some problems. Why does this crash on the NSJSONSerialization
line? Is there a better way to download info from this website?
EDIT: I changed jsonArray from a NSArray to a NSDictionary, but it still crashes in the same spot. Is there a different way to download this data?
NSString *url=@"https://api.p04.simcity.com/simcity/rest/users/search/J3d1.json";
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLResponse *resp = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest: theRequest returningResponse: &resp error: &err];
NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData: response options: NSJSONReadingMutableContainers error: &err];
NSLog(@"%@",jsonArray);
For reference, the JSON is:
{
"users": [
{
"uri": "/rest/user/20624",
"tutorialState": 0,
"nucleusId": 20624,
"id": 20624,
"screenName": "R3DEYEJ3D1",
"lastLogin": 1362666027000,
"isOnline": "true",
"avatarImage": "https://api.p04.simcity.com/simcity/rest/user/20624/avatar",
"cities_count": 0,
"canChat": "true"
},
{
"uri": "/rest/user/46326",
"tutorialState": 0,
"nucleusId": 46326,
"id": 46326,
"screenName": "J3D1_WARR10R",
"lastLogin": 1363336534000,
"isOnline": "false",
"avatarImage": "https://api.p04.simcity.com/simcity/rest/user/46326/avatar",
"cities_count": 0,
"canChat": "true"
}
]
}