# UITableView简单性能优化

**URL:** <https://www.shiqidu.com/t/topic/500>\
**Category:** 开发调优\
**Tags:** C-C-Obj-C\
**Created:** [2018 年10 月 5 日 06:14 UTC](https://www.shiqidu.com/t/topic/500 "2018-10-05T06:14:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2018 年10 月 5 日 06:14 UTC](https://www.shiqidu.com/t/topic/500/1 "2018-10-05T06:14:51Z")

</div>

记录一下

```oc
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"a";
    // 从缓存池中取可重复调用的cell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    // 如果没有，创建一个新的cell
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"第%ld行", indexPath.row];
    
    return cell;
}

```
