我正在使用Instruments來監視內存使用情況。我注意到內存總是增加,而不是在我的UITableViewController上釋放。我不明白爲什麼。下面我列出我的代碼如何使用UITableViewController釋放內存
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
int row = [indexPath section];
static NSString *CellIdentifier = @"ApplicationCell";
BookCell *cell = (BookCell *)[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"BookCell" owner:self options:nil];
cell = bookCell;
self.bookCell=nil;
}
Book *book = [books objectAtIndex:row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.bookNameLabel.text = book.author;
cell.bookPriceLabel.text = book.price;
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
什麼是儀器告訴你沒有發佈?通常它會告訴你什麼類沒有被釋放,以及在調用堆棧中的什麼地方。 – 2009-12-21 09:07:22
我解決了這個問題。我忘了在我自己定製的CellView中釋放一些元素 – 2009-12-22 01:06:15