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]: unrecognized selector sent to instance 0x7fd4d15211d0
这是我的 TableView 方法:
-(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;
}
任何帮助将不胜感激。提前致谢。
最佳答案
如果 _Contact 是 NSMutableArray 类型,那么试试这个,否则替换类型:
_Contact = [[NSMutableArray alloc] init];
关于ios - 为什么我会收到错误 -[__NSArrayM length] : unrecognized selector sent to instance 0x7fd4d15211d0 while assigning data to custom tableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37002796/