I have a list of items, and in a modal view controller, i have what is effectively a ‘New item’ screen, where a user can type in a new thing for the list.
The list is a UITableView, with data source, NSMutableArray.
here is the code on the MVC
-(IBAction)done{
[RoutineTitle resignFirstResponder];
[RoutineInvolvment resignFirstResponder];
NSString *myString = RoutineTitle.text;
FirstViewController *FirstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
NSLog(@"Log the String: %@", myString);
[FirstView.routines addObject:myString];
[self dismissModalViewControllerAnimated:YES];
}
But, then when returned to the regular screen, it does not show up. im not sure if its not adding it to the array correctly, or if the table view needs to refresh or what.
Any help would be appreciated.
Thanks
Sam
Your code doesn’t make any sense. Are you calling -presentModalViewController in your FirstViewController? Why are you instantiating a new FirstViewController in your -done method?
What you need to do when you present your ‘new item’ view controller is pass it a reference to your table view and data container. Something like this:
Then, in your -done: action of your new item view controller you can add the string to the data container (NSMutableArray) and then reload the table view like this:
Your NewItemViewController will need two @syntheisze’d ivars like this:
Let me know if you need clarification.