- 創(chuàng)建屬性 dataSource
@property (nonatomic, strong) NSMutableArray *dataSource;
2.懶加載并初始化 數(shù)據(jù)源
- (NSMutableArray *)dataSource
{
if (_dataSource == nil) {
_dataSource = [NSMutableArray array];
}
return _dataSource;
}
3.請求省略 獲取到array數(shù)據(jù)插入
//在第loc(loc可為0)個(gè)元素處插入長度為len的一組對象.當(dāng)loc == 0時(shí),表示將這組對象插入到原數(shù)組的最前面.
[self.dataSource insertObjects:array atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, array.count)]];
4.cell展示 使第array.count - 1cell顯示在屏幕頂部 動(dòng)畫為NO
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:array.count - 1 inSection:0];
[self.tableView scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];