Hello. I suppose this should be very easy, but I'm stuck and I need your help.
I'm working in a "Utility Application". In the main view I have a TextField, a Button and a TableView. This TableView is filled with items on an array. All I want is to write something in the text field, and add that text as a new cell in the TableView.
The "cellForRowAtIndexPath" loads correctly the table with the values in the array at the begining, but it is not called when I add more items to the array. I have tried the following:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.array addObject:textInput.text];
NSIndexPath *ip = [NSIndexPath indexPathForRow:num inSection:0];
NSArray *arr = [NSArray arrayWithObjectNSIndexPath *)ip];
[tableView insertRowsAtIndexPaths:arr withRowAnimation:YES];
Also, I tried calling [tableView reload]. In both cases, the array adds the item correctly, but the TableView doesn't show the changes.
I have read the documentation and checked the samples, but I haven't found one where the items are inserted entirely with code. I would appreciate your help. Thank you.
I'm working in a "Utility Application". In the main view I have a TextField, a Button and a TableView. This TableView is filled with items on an array. All I want is to write something in the text field, and add that text as a new cell in the TableView.
The "cellForRowAtIndexPath" loads correctly the table with the values in the array at the begining, but it is not called when I add more items to the array. I have tried the following:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.array addObject:textInput.text];
NSIndexPath *ip = [NSIndexPath indexPathForRow:num inSection:0];
NSArray *arr = [NSArray arrayWithObjectNSIndexPath *)ip];
[tableView insertRowsAtIndexPaths:arr withRowAnimation:YES];
Also, I tried calling [tableView reload]. In both cases, the array adds the item correctly, but the TableView doesn't show the changes.
I have read the documentation and checked the samples, but I haven't found one where the items are inserted entirely with code. I would appreciate your help. Thank you.