gpt4 book ai didi

iphone - UITableView 中的错误

转载 作者:行者123 更新时间:2023-11-28 23:08:51 25 4
gpt4 key购买 nike

我正在创建一个 UITableView,代码中的一切都很好并且构建成功,但是当我在模拟器中运行时。它显示错误为:

Thread 1: Program received signal :"EXC_BAD_ACCESS".

在下面找到我的代码供您引用:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"Mycell"];
if(cell == nil){
cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MYcell"]autorelease];
}
cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1];

return cell;
}

错误在这一行:

cell.textLabel.text=[NSString stringWithFormat:@"cell %@",(unsigned long)indexPath.row+1];

请发表您的建议

最佳答案

您使用了错误的格式说明符。 %@ 用于对象,使用 %d 用于整数:

cell.textLabel.text=[NSString stringWithFormat:@"cell %d",(unsigned long)indexPath.row+1];

关于iphone - UITableView 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8739053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com