I’m a little confused how to use IndexPath to add row into TableView.
In first i init:
tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
//rows code here
[self.view addSubview:tableView];
Now between this two i would like to add some row to my table View. I have an NSArray with NSStrings contains elements name.
So i try this:
[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:(NSArray *)myNames withRowAnimation:UITableViewRowAnimationNone];
[[self tableView] endUpdates];
Then I’ve read that I should first add this somehow to UITableViewDataSource. So i declared it wrong? I’m asking becouse i’d rather avoid unnecessary passing data.
The idea of the table view – and most views in MVC – is that they reflect the state of the model. So, yes, as you suggested, have your datasource maintain an array:
Make changes to the array:
Record what rows have changed…
Then let the table view know that the model is different using the code you posted…