ios - 为什么我会收到错误 -[__NSArrayM length] : unrecognized selector sent to instance 0x7fd4d15211d0 while assigning data to custom tableView

标签 ios uitableview nsarray nsmutabledictionary

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/

相关文章:

ios - 插入内联日期选择器 View 单元格 - swift

arrays - Swift:如何将一个字符串数组拆分为多个匹配值的数组?

ios - 可以使用 Storyboard 来表示条件屏幕流吗?

ios - xcodebuild 错误方案未配置运行

iphone - Facebook 图形 API 答案延迟

ios - 在 uiscrollview 中实现带有更改按钮的 uitableview

iphone - 充满 NSDictionaries 的 NSArray。如何找到对象的索引?

objective-c - 替换数组中的对象不起作用,但添加一个新对象可以

objective-c - 检查 NSArray 中 NSDictionary 的键是否存在的更好选择?

ios - 此应用程序不能摇 TreeMap 标字体