From the modalViewController (UniversitiesViewController *), I’ve tried to set a variable in the rootViewController with no luck. In my tableview:didSelectRowAtIndexPath: method I use the following code to set the rootViewController (MapsViewController *) selectedIndex property:
MapsViewController *mapsView = (MapsViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"MapsView"];
mapsView.selectedIndex = [NSNumber numberWithInt:indexPath.row];
[self dismissModalViewControllerAnimated:YES];
When I print the value of self.selectedIndex in the MapViewController it is always 0, which is not the value selected.
Thanks in advance for your help.
The correct way to do this is to create a delegate protocol for the UniversitiesViewController.
And add
to the UniversitiesViewController class.
In didSelectRow in the UniversitiesViewController, call
Then from MapsViewController, when instantiating UniversitiesViewController (or if using segues, in prepareForSegue) set the delegate to ‘self’. And make MapsViewController handle the delegate method.