-2

テーブルビューにいくつかのアイテムをリストする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」という情報をデバッグする方法を教えてください。

次の方法で tableivew にデータを追加しています。

- (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; 
}
4

1 に答える 1

1

@Gijoテーブルセルで使用している、または何かを

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

すでにリリースされているメソッド、つまりオブジェクト、ラベルなど。

于 2012-03-23T04:32:57.437 に答える