The problem is your JSON's root object is an array:
[ … ]
but you're incorrectly assuming it's a dictionary:
NSDictionary *jsonData = (NSDictionary *)[jsonParser objectWithString:responseData error:nil];
You could do something like this if the response will always be an array with one object:
NSArray *jsonArray = (NSArray *)[jsonParser objectWithString:responseData error:nil];
NSDictionary *jsonData = [jsonArray lastObject];
But a safer approach is to inspect the class:
NSObject *object = [jsonParser objectWithString:responseData error:nil];
if ([object isKindOfClass:[NSArray class]]) {
// it's an array …
} else if ([object isKindOfClass:[NSDictionary class]]) {
// it's a dictionary …
}
Finally,
- You should probably use NSJSONSerialization instead of SBJSON.
- You should not pass
nil
in for the error argument; you should add error handling.