NSMutableDictionary *persondict=[[NSMutableDictionary alloc]init];
[persondict setObject:fullName forKey:@"givenName"];
[persondict setObject:identity forKey:@"identifier"];
[persondict setObject:_mobnumberarray forKey:@"CNLabelPhoneNumberMobile"];
[persondict setObject:_iphoneArray forKey:@"CNLabelPhoneNumberiPhone"];
[_Contacts addObject:persondict];
上面是我填充了两个数组的字典,但是当我尝试在tableview上显示_Contacts数组时,它会在控制台屏幕上显示以下错误:
[__ NSArrayM length]:发送到实例的无法识别的选择器 0x7fd4d15211d0
以下是我的表格查看方法:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
{
return _Contacts.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"tableViewCell";
tableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.celll.text = [[_Contacts objectAtIndex:indexPath.row]valueForKey:@"givenName"];
cell.idcell.text=[[_Contacts objectAtIndex:indexPath.row]valueForKey:@"identifier"];
cell.numbercell.text=[[_Contacts objectAtIndex:indexPath.row]valueForKey:@"CNLabelPhoneNumberMobile"];
cell.iphonecell.text=[[_Contacts objectAtIndex:indexPath.row]valueForKey:@"CNLabelPhoneNumberiPhone"];
return cell;
}
任何帮助将不胜感激。提前谢谢。
答案 0 :(得分:3)
如果_Contact属于NSMutableArray类型,那么试试这个,否则替换类型:
_Contact = [[NSMutableArray alloc] init];