gpt4 book ai didi

ios - 滚动 UITableView 时出现 EXC_BAD_ACCESS 错误

转载 作者:行者123 更新时间:2023-11-29 13:48:07 25 4
gpt4 key购买 nike

我已经从在 AppDelegate 中声明的数组中将我的应用程序数据加载到 UITableView 中。但是,当我尝试滚动 TableView 时,出现 EXC_BAD_ACCESS 错误。以下是我用于配置单元格的代码。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ScoutAppDelegate *appDelegate = (ScoutAppDelegate *)[[UIApplication sharedApplication] delegate];
return appDelegate.playerList.count;

}

- (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] autorelease];
}

ScoutAppDelegate *appDelegate = (ScoutAppDelegate *)[[UIApplication sharedApplication] delegate];
Player *tempPlayer = (Player *)[appDelegate.playerList objectAtIndex:indexPath.row];

cell.textLabel.text= tempPlayer.playerName;
return cell;
}

最佳答案

好吧,似乎是在我为委托(delegate)数组填充对象时,我没有在属性前使用“self”一词,这导致每次都将指针设置为第一个元素,并最终在我尝试向下滚动时使我的程序崩溃。非常感谢所有评论。

关于ios - 滚动 UITableView 时出现 EXC_BAD_ACCESS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6430047/

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