3
我很确定我在这里做的是正确的,但我只是想检查[cell autorelease]
是不是太快释放我的单元格,并且dequeueReusableCellWithIdentifier
排队等待重用的单元格。我的理解是,队列是一个单独的实体,就像存储单元格蓝图一样(有点像笔尖),而不是实际的对象?UITableViewCell,出队和autorelease?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LOC_ID"];
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LOC_ID"];
[cell autorelease];
}
NSUInteger row = [indexPath row];
//id thisLocation = [locationList objectAtIndex:row];
[[cell textLabel] setText:[NSString stringWithFormat:@"R_%u", row]];
return cell;
}
编辑:为了澄清,我感兴趣的是关于生命周期和细胞会发生什么。我知道我分配他们,然后autorelease他们,然后表格从cellForRowAtIndexPath返回后获取单元格的所有权?所以他们十个属于UITableView,或者我感到困惑?