我的iPad应用程序面临很少的内存泄漏。这里是屏幕截图和代码。我每秒后都会加载表格数据以显示进度。我该怎样才能得到这个修复。
当我重新加载表
时总会发生这种情况// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* Identifier = @"OrderCustomCell";
UserCustomCell* cells =(UserCustomCell*) [tableView dequeueReusableCellWithIdentifier:Identifier];
if (cells == nil)
{
NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[UITableViewCell class]])
{
cells=(UserCustomCell *)currentObject;
break;
}
}
}
NSDictionary* dic = [tableDataArray objectAtIndex:indexPath.row];
cells.selectionStyle = UITableViewCellEditingStyleNone;
cells.brandName.text = [dic objectForKey:@"brandname"];
[cells.msyncBtn setTag:indexPath.row];
NSString* status = [dic objectForKey:@"status"];
if ([status isEqualToString:@""])
{
cells.status.text = [NSString stringWithFormat:@"0%@ Completo",@"%"];
}
else
{
cells.status.text = [NSString stringWithFormat:@"%@%@ Completo",status,@"%"];
}
NSString* syncDate = [dic objectForKey:@"syncDate"];
if ([syncDate isEqualToString:@""])
{
cells.syncDate.text = [NSString stringWithFormat:@"Não sincronizado"];
}
else
{
cells.syncDate.text = [NSString stringWithFormat:@"%@",syncDate];
}
NSString* totalloaded = [dic objectForKey:@"totalloaded"];
if ([totalloaded isEqualToString:@""])
{
cells.totalLoaded.text = [NSString stringWithFormat:@""];
}
else
{
cells.totalLoaded.text = [NSString stringWithFormat:@"%@",totalloaded];
}
return cells;
}
请检查此图片
答案 0 :(得分:0)
试试这个
if (cells == nil)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[UITableViewCell class]])
{
cells=(UserCustomCell *)currentObject;
break;
}
}
[pool drain];
}