iphone:UITABLEView使应用程序崩溃

iphone:UITABLEView使应用程序崩溃,iphone,uitableview,sqlite,Iphone,Uitableview,Sqlite,不知道我的表视图有什么问题,我有一个字典(这个字典是由sqlite操作创建的),我正在尝试创建这样的单元格 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; MyIdentifier = @"tblCellView"; CustomCel

不知道我的表视图有什么问题,我有一个字典(这个字典是由sqlite操作创建的),我正在尝试创建这样的单元格

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

static NSString *MyIdentifier = @"MyIdentifier";
MyIdentifier = @"tblCellView";

CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
    cell = aCustomCell;
    aCustomCell=nil;
}

NSMutableDictionary *tempDictionary=[[NSMutableDictionary alloc] init];

tempDictionary=[offendersNamesList objectForKey:[NSString stringWithFormat:@"key%d", indexPath.row+1]];

[[cell offendersImageView] setImage:[UIImage imageNamed:@"contact.png"]];
[cell.offendersNameLbl setText:[tempDictionary objectForKey:@"name"]];
[cell.offendersViolation setText:[tempDictionary objectForKey:@"offence"]];
[tempDictionary release];

//[cell setLabelText:[arryData objectAtIndex:indexPath.row]];
return cell;
}


所有项目都正确显示,但当我向上滚动表格视图时,应用程序崩溃。您能帮我解决这个问题吗?

您首先要分配一个新的NSMutableDictionary,并将其存储在
临时Dictionary
中。但是,在下一行中,您将使用指向新对象的指针覆盖该变量(
tempdoictionary=[IncratersNameslistObjectForkey:[NSString stringWithFormat:@“key%d”,indexath.row+1];
)。因此,这里存在内存泄漏,
[[NSMutableDictionary alloc]init]
是不必要的,请删除它

现在,由于命名约定,您从
冒犯者名称列表
获得的对象被自动删除,但您稍后调用
[tempDictionary release]并因此过度释放它。把它也去掉