My parent ViewController class contains a UISearchBar. I have a UIButton that will push on a new ViewController via the code below
AddViewController *addViewController = [[AddViewController alloc] initWithNibName:@"AddView" bundle:nil];
[self presentModalViewController:addViewController animated:YES];
[addViewController release];
In the AddViewController the User is presented with a TableView of animal names. On the
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
I extract the the animal name and store it in an NSString. I then dismiss the AddViewController by
[self dismissModalViewControllerAnimated:YES];
My Question is How do I pass the NSString animal name to the Parent ViewController of AddViewController? I'm attempting to place the animal name in the UISearchBar
You could create a property in the parent view controller which you can then update from the child by calling
When the child is dismissed, set the UISearchBar text in the parent's viewWillAppear method
You would need to create a Delegate.
http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html
These allow you to communicate with the parent view controller, and in your case, pass a variable.