绑定表格
数据源
定义属性
@property (nonatomic, strong) NSArray *dataList;
setter方法
- (void)setDataList:(NSArray *)dataList {
_dataList = dataList;
[self.tableView reloadData];
}
数据源方法
#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text = [self.dataList[indexPath.row] name];
return cell;
}
设置数据源方法
- (void)parserDidEndDocument:(NSXMLParser *)parser {
NSLog(@"5. 解析结束");
NSLog(@"%@ %@", self.videos, [NSThread currentThread]);
dispatch_async(dispatch_get_main_queue(), ^{
self.dataList = self.videos;
});
}
自定义 Cell