如何将响应对象强制转换为对象

时间:2017-02-06 12:25:22

标签: objective-c

[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);
        }



}

它给了我错误:

  

由于未捕获的异常'NSUnknownKeyException'而终止应用,   原因:'[< __ NSCFString 0x79ea4430> valueForUndefinedKey:]:这个类   对于密钥AccessKeyId'

,不符合密码值编码

1 个答案:

答案 0 :(得分:0)

试试这个:

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:MyApplication.Desktop.Client.Behaviors"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:command="http://www.galasoft.ch/mvvmlight"