我正在準備像這樣的定製單元格 1)創建了一個定製單元格與Xib 2)因爲我必須更改自定義單元格中的對應於值讀取從數據庫。我不能重複使用相同的cellIdentifieriphone:在內存消耗和內存泄漏的情況下表格視圖
static NSString *MyIdentifier = @"MyIdentifier";
MyIdentifier = [NSString stringWithFormat:@"Cell %d",indexPath.row];
NSString *offendersImagePath = [self applicationDocumentsDirectory];
offendersImagePath=[offendersImagePath stringByAppendingPathComponent:@"Images"];
CustomOffendersCell *cell = (CustomOffendersCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomOffendersCell" owner:self options:nil];
cell = aCustomOffendersCell;
aCustomOffendersCell=nil;
}
NSMutableArray *tempArray;//=[[NSMutableDictionary alloc] init];
tempArray=[offendersNamesList objectAtIndex:indexPath.row];
的代碼都像上面時,我檢查了儀器的表現泄露這件事對於這條線和高內存消耗
[[NSBundle mainBundle] loadNibNamed:@"CustomOffendersCell" owner:self options:nil];
你可以建議我一些方法來擺脫這個
但'cell'指向同一個對象。可能autorelease? – 2011-06-04 07:26:19
@Deepak:對,但(** cell **實例)將由'tableView'保留,那麼** aCustomOffendersCell **呢? – Jhaliya 2011-06-04 07:28:07
是的,但它必須保持活力,直到方法結束。 'release'將主要銷燬'cell'指向的對象。但這是泄漏。 – 2011-06-04 07:31:36