0
通常,當我設置UITableViewCell
時,我使用默認的cellStyles,根據需要分配和自動釋放單元。我的問題是關於下面例子中的內存管理。 FGCustomCell
分配在哪裏,當我要求包含在筆尖中的對象時創建它?我也假設它的autoreleased,所以下面的代碼是好的?使用來自NIB的UITableViewCells進行內存管理?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FGCustomCell *customCell = (FGCustomCell *)[tableView dequeueReusableCellWithIdentifier:@"FGCELL_ID"];
if(customCell == nil) {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"FGCustomCell" owner:self options:nil];
for(id eachObject in nibObjects) {
if([eachObject isKindOfClass:[FGCustomCell class]]) customCell = (FGCustomCell *)eachObject;
}
}
return customCell;
}