[__ NSCFDictionary objectAtIndex:]:无法识别的选择器发送到实例0x7b0bb4b0 2014-10-15 11:32:53.278阿拉伯人[635:26220] ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSCFDictionary objectAtIndex:]:无法识别的选择器发送到实例0x7b0bb4b0'
我在这里面对这个错误......请帮帮我
NSDictionary *dic=[self.homeDataDictionary objectForKey:@"co_home_business_interview"];
NSArray *firstArray = [dic objectForKey:@"co_home_business"];
NSArray *secondArray = [dic objectForKey:@"co_home_interview"];
TitleButtonLabel *titleLabel1 = [[TitleButtonLabel alloc] initWithFrame:CGRectMake(130, 490, 161, 21)];
titleLabel1.section = indexPath.section;
titleLabel1.row = 1;
[cell.contentView addSubview:titleLabel1];
NSString *titlestr=[Utility stringByStrippingHTML:[[firstArray objectAtIndex:0] objectForKey:@"title"]];
[titleLabel1 setTitle:titlestr forState:UIControlStateNormal];
titleLabel1.titleLabel.textAlignment = NSTextAlignmentRight;
titleLabel1.titleLabel.numberOfLines = 1;
titleLabel1.lineBreakMode = UILineBreakModeWordWrap | UILineBreakModeTailTruncation;
[titleLabel1 setTitleColor:[UIColor colorWithRed:221/255.0f green:0/255.0f blue:26/255.0f alpha:1.0f] forState:UIControlStateNormal];
[titleLabel1 setTitleColor:[UIColor colorWithRed:0/255.0f green:204/255.0f blue:0/255.0f alpha:1.0f] forState:UIControlStateHighlighted];
[titleLabel1 addTarget:self action:@selector(titleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
答案 0 :(得分:2)
您的一个变量firstArray
或secondArray
并不真正指向数组,而是指向字典。拨打objectAtIndex:
答案 1 :(得分:0)
检查self.homeDataDictionary
字典的数据结构。如果您发现其中有NSDictionaries
,那该怎么办?您可能缺少一些括号()
我的意思是NSArray
,只有一个对象看起来像NSDictionary
结构。再次验证从self.homeDataDictionary
返回的对象是NSDictionary
而不是NSArray
。
在进一步操作之前,还要先NSLog
检查返回对象类型。
NSArray *firstArray = [dic objectForKey:@"co_home_business"];
NSArray *secondArray = [dic objectForKey:@"co_home_interview"];
上面两行似乎有些错误。对象dic
可能是NSArray
。并检查其返回值并确保其为NSArray
而不是NSDictionary