に新しい行を追加できませんUITableview
。コードは次のとおりで、次のエラーが表示されます
-(void)viewDidLoad
{
self.title=@"CHECK-list";
self.navigationItem.rightBarButtonItem = self.editButtonItem;
addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItem)];
self.navigationItem.leftBarButtonItem = addButton;
ar=[[NSMutableArray alloc]initWithObjects:@"Map",@"Camera",@"First Aid Kit", nil];
[super viewDidLoad];
}
- (void)addItem
{
//NSMutableArray *tempArray = [[NSMutableArray alloc] init];
int i = 0;
for (NSArray *count in ar)
{
[ar addObject:[NSIndexPath indexPathForRow:i++ inSection:1]];
}
[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:(NSArray *)ar withRowAnimation:UITableViewRowAnimationNone];
[[self tableView] endUpdates];
[self.tableView reloadData];
}