【问题标题】:Zombie Error during TreasureList tableView:didSelectRowAtIndexPath [closed]TreasureList tableView期间的僵尸错误:didSelectRowAtIndexPath [关闭]
【发布时间】:2012-03-23 04:25:10
【问题描述】:

我正在开发一个在表格视图中列出一些项目的 iPhone 应用程序。我在单击某个项目时遇到事件 TreasureList tableView:didSelectRowAtIndexPath 错误。我对这个错误感到困惑。错误是

[TreasureList tableView:didSelectRowAtIndexPath:]: message sent to deallocated instance 0x7ce0020

代码如下:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

ProductModel *data=[[ProductModel alloc]init];
  data=[self.treasureData objectAtIndex:indexPath.row];

pid=  [NSString stringWithFormat: data.ID];//WithFormat:@"%@",data.ID];   

还请告诉我如何调试信息“deallocated instance 0x7ce0020”

我正在通过以下方式将数据添加到表格中。

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView
                         dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                  reuseIdentifier:SimpleTableIdentifier] autorelease];
}
ProductModel *data=[self.treasureData objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:data.pName];
   [data
    release];
return cell; 
}

【问题讨论】:

  • 谁能帮助你?没有代码,没有错误信息,什么都没有。您需要包含相关代码。
  • 添加代码以实现 didSelectRowAtIndexPath 以及与之交互的任何属性、对象、函数
  • 对不起,我已经提供了代码
  • ProductModel *data=[[ProductModel alloc]init];数据=[self.treasureData objectAtIndex:indexPath.row];这两行没有意义:-P,当您从数组中使用它时,您不需要分配“数据”,我确信这个“数据”正在被释放并且您稍后会在某个地方使用它,什么属性类型你用过'treasureData'吗
  • 如果您在将这些 ProductModel 对象添加到数组时没有在某处放置额外的保留/复制,则无需释放数据对象。

标签: iphone zombie-process


【解决方案1】:

@Gijo 您可能会收到此错误,因为某些已发送的消息已发送到您在表格单元格中使用的已发布对象,或者当您尝试在

中使用某些内容时
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

方法,已经发布了一些对象,标签等。

【讨论】:

  • 这与自定义单元格有关吗?
  • 是的,很有可能,请输入一些代码并相应地更新您的问题。在询问与崩溃或其他相关的任何内容时,总是会感谢代码:-)
  • 我用我用来填充 Tableview 的代码修改了我原来的问题。
  • 我终于通过释放一些对象解决了这个问题。感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-02
  • 2013-01-18
  • 1970-01-01
  • 2011-08-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多