[英]__NSCFConstantString objectForKey unrecognized selector sent to instance error
I basically get this error 我基本上得到这个错误
'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x581f0'
on my program. 在我的程序上。 I think it refers to this call I make,
我认为这是指我打的这个电话,
if (data != nil) {
if([data objectForKey:@"username"]){
// NSArray *check= [[NSArray alloc]init];
//check=[data allValues];
[dict setObject:[data allValues] forKey:@"args"];
}else{
[dict setObject:[NSArray arrayWithObject:data] forKey:@"args"];
}
at the setObject:[data allValues]. 在setObject:[data allValues]。 I don't know why it gives that error but data is an NSDictionary and I'm getting all the values and placing it in an array.
我不知道为什么会出现该错误,但是数据是一个NSDictionary,我正在获取所有值并将其放置在数组中。
Is the error happening here: 错误发生在这里:
if([data objectForKey:@"username"]){
I assume so, as that is the only place objectForKey seems to be called. 我认为是这样,因为这似乎是唯一调用objectForKey的地方。 You are calling it on a variable called 'data', which i'm guessing simply is not a dictionary.
您在名为“数据”的变量上调用它,我猜这根本不是字典。 You should NSLog its type to see.
您应该使用NSLog的类型来查看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.