[英]Terminating app due to uncaught > exception 'NSInvalidArgumentException'
This seems like it should be pretty straight forward - but alas, I'm getting a crash.这看起来应该很简单 - 但唉,我遇到了崩溃。 I'm simply trying to set my UILabel with the text returned from the users_name field:我只是想用从users_name字段返回的文本来设置我的 UILabel :
.m .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]);
}];
The console data returns:控制台数据返回:
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;
},
That said, this line is causing the crash:也就是说,这条线导致了崩溃:
self.username.text = [self.userData objectForKey:@"users_name"];
And this is the error:这是错误:
2016-04-05 12:25:36.878 [1331:350069] -[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x15a23c100 2016-04-05 12:25:36.881 [1331:350069] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x15a23c100' * First throw call stack: (0x181d51900 0x1813bff80 0x181d5861c 0x181d555b8 0x181c5968c 0x1000cce9c 0x1000c72bc 0x1000d3cc4 0x100459bf0 0x100459bb0 0x10045f658 0x181d08bb0 0x181d06a18 0x181c35680 0x183144088 0x186aacd90 0x1000d4c88 0x1817d68b8) libc++abi.dylib: terminating with uncaught exception of type NSException 2016-04-05 12:25:36.878 [1331:350069] -[__NSCFArray objectForKey:]:无法识别的选择器发送到实例 0x15a23c100 2016-04-05 12:25:36.8189到 * 103 Terminate 异常: * 103 '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 类型的未捕获异常终止
How might I fix this?我该如何解决这个问题? It seems like it should be simple...好像应该很简单……
I suppose userData
is an Array type.我想userData
是一个数组类型。 Array have no key values.数组没有键值。 Try:尝试:
[[self.userData objectAtIndex:0] objectForKey:@"users_name"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.