由于未被捕获而终止应用程序>异常' NSInvalidArgumentException'

时间:2016-04-05 19:33:27

标签: ios objective-c

这似乎应该非常直接 - 但是,唉,我遇到了崩溃。我只是尝试使用 users_name 字段返回的文本设置我的UILabel:

的.m

NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:@"u000" forKey:@"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {


   self.userData = [responseObject mutableCopy];

   self.username.text = [self.userData objectForKey:@"users_name"];

   dispatch_async(dispatch_get_main_queue(), ^(void){

    });


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Failure: %@", [error localizedDescription]);
}];

控制台数据返回:

2016-04-05 12:25:36.877 [1331:350069] This is the Other User Data (
        {
        address = "Vancouver";
        userbio = "There is currently no bio available for this user. If you have added your bio, and require assistance, please contact the  Team.";
        "users_name" = Brittany;
    },

那就是说,这条线导致了崩溃:

self.username.text = [self.userData objectForKey:@"users_name"];

这是错误:

  

2016-04-05 12:25:36.878 [1331:350069] - [__ NSCFArray objectForKey:]:   无法识别的选择器发送到实例0x15a23c100 2016-04-05   12:25:36.881 [1331:350069] *由于未被捕获而终止应用   异常' NSInvalidArgumentException',原因:' - [__ NSCFArray   objectForKey:]:无法识别的选择器发送到实例0x15a23c100'   * 第一次抛出调用堆栈:(0x181d51900 0x1813bff80 0x181d5861c 0x181d555b8 0x181c5968c 0x1000cce9c 0x1000c72bc 0x1000d3cc4   0x100459bf0 0x100459bb0 0x10045f658 0x181d08bb0 0x181d06a18   0x181c35680 0x183144088 0x186aacd90 0x1000d4c88 0x1817d68b8)   libc ++ abi.dylib:以未捕获的类型异常终止   NSException

我该如何解决这个问题?看起来应该很简单......

1 个答案:

答案 0 :(得分:0)

我认为and是一种数组类型。数组没有键值。 尝试:
userData