我想填充我的UITableView
来自我的 NSMutableArray
的数据但它得到了一个异常(exception)。
异常(exception):
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM isEqualToString:]: unrecognized selector sent to instance 0xa2ba880'
我的 cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [callDetailArray objectAtIndex:indexPath.row];
[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
return cell;
}
这是数组:
Array: (
{
callId = 3;
callKeyword = CALL100;
callName = "Call to All";
callNumber = 5908;
}
)
我想要发生的是我的
UITaleView
中的单元格将显示 callId
中的数据, callKeyword
, callName
和 callNumber
.
最佳答案
在你CellDetailArray
数据输入 Dictionary
所以您可以从 NSMutableArray
获取详细信息像贝娄:-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSMutableDictionary *d=(NSMutableDictionary*)[callDetailArray objectAtIndex:indexPath.row];
cell.textLabel.text =[d valueForKey:@"callName"];
[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
return cell;
}
如果您想在 TableCell 中显示所有四个值,则必须创建具有四个 UIlable 和 Sate 值的 customeCell,例如:-
YourLable1.text =[d valueForKey:@"callId"];
YourLable2.text =[d valueForKey:@"callKeyword"];
YourLable3.text =[d valueForKey:@"callName"];
YourLable4.text =[d valueForKey:@"callNumber"];
关于iphone - 使用 NSMutableArray 中的数据填充 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14994969/