我运行这个函数:
- (void)insertRows {
[_objects insertObject:[NSDate date] atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
它必须运行这个函数
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSDate *object = _objects[indexPath.row];
cell.textLabel.text = [object description];
return cell;
}
但是这个功能没有运行...请帮助如何运行tableView...功能
- (IBAction)insertObject {
[[MasterViewController alloc] insertRows];
}
- 此代码运行 insertRows,我通过断点检查
- (IBAction)insertObject:(id)sender {
[_objects insertObject:[NSDate date] atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
NSLog(@"log:insert-indexPath: %i",indexPath.row);
NSDate *object = _objects[indexPath.row];
NSLog(@"log:insert-object %@",object.description);
}
- 使用它,为什么?