I've been down this road before. I am adding a blank cell to my tableview when the user presses the add button. The cell that is created is a custom cell with a UITextField. So I am adding an empty string object to my locationKeys mutableArray (my data source for the tableview). It works the first time but crashes when I try to add another item to the array.
My question as I am working through this is the error. Is the "unrecognized selector" referring to the locationKeys mutableArray which is the receiver or the instance, or is it the item that I am trying to send to it that is not there? Which in this case is just an empty string?
I am baffled why it works the first time and not the second?
Code:
-(void)addindexRow{
int rowForInsert = locationKeys.count;
[locationKeys insertObject:@"" atIndex:rowForInsert];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowForInsert inSection:0];
NSArray* path = [NSArray arrayWithObject:indexPath];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationBottom];
[self.tableView endUpdates];
[self.tableView reloadData];
}
My question as I am working through this is the error. Is the "unrecognized selector" referring to the locationKeys mutableArray which is the receiver or the instance, or is it the item that I am trying to send to it that is not there? Which in this case is just an empty string?
I am baffled why it works the first time and not the second?
2012-06-20 15:04:23.415 Got Gear[13215:f803] -[__NSArrayI insertObject:atIndex:]: unrecognized selector sent to instance 0x6818720