私はこの機能を実行します:
- (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);
}
-それで動作します、なぜですか?