Reputation: 13
[manager POST:urlString parameters:[self jsonDict] success:^(AFHTTPRequestOperation *operation, id responseObject){
NSLog(@"response data: %@", responseObject);
NSArray *postFromResponse = [ responseObject valueForKeyPath:@"credentials"];
NSLog(@"credentials:%@", postFromResponse);
for(NSDictionary *object in postFromResponse)
{
NSString *AccessKeyId = [object valueForKeyPath:@"AccessKeyId"];
NSLog(@"%@", AccessKeyId);
}
}
It gives me error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x79ea4430> valueForUndefinedKey:]: this class is not key value coding-compliant for the key AccessKeyId'
Upvotes: 1
Views: 185
Reputation: 156
Try this:
NSMutableDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSArray *postFromResponse = [responseDict valueforkey:@"credentials"];
for(NSDictionary *object in postFromResponse) {
NSString *AccessKeyId = [object valueforkey:@"AccessKeyId"];
NSLog(@"%@", AccessKeyId);
}
Upvotes: 0