I have a text field in my app. I am trying to store whatever is entered into the text field in an array and display it in my root view controller (which is a table view) on click of a button.
The method for the button is as follows:
-(IBAction)addNewCountry:(id)sender
{
[rootViewController.details addObject:nameField.text];
NSLog(@"Country name is %@", rootViewController.details);
[self.navigationController pushViewController:rootViewController animated:YES];
[rootViewController.tableView reloadData];
NSLog(@"new country added");
}
details is the array declared in RootViewController
However, the text field text is not retrieved. Can anybody tell me what am i missing?
You cont directly insert your string data to your array, you need to store as a string
then add it in to your string using addobject