I\'ve created a login page which uses Restkit RKClient to send login details, and get back JSON data (either the user or an error). I want to be able to parse t
You can simply call parsedBody:nil on your RKResponse object and assign the returned object to an NSDictionary:
responseDict = [response parsedBody:nil];
And as an extra check I use a little convenience method to check for a a successful response:
- (bool) wasRequestSuccessfulWithResponse:(RKResponse*)response {
bool isSuccessfulResponse = NO;
id parsedResponse;
NSDictionary *responseDict;
if(response != nil) {
parsedResponse = [response parsedBody:nil];
if ([parsedResponse isKindOfClass:[NSDictionary class]]) {
responseDict = [response parsedBody:nil];
if([[responseDict objectForKey:@"success"] boolValue]) {
isSuccessfulResponse = YES;
}
}
}
return isSuccessfulResponse;
}