In DetailViewController.h add a property to the object pointing to MasterViewController. You will also need to import MasterViewController.h, something like
#import "MasterViewController"
...
@property (non-atomic, save) MasterViewController * mVc;
...
Remember in DetailViewController.m to @synthesize mVc;
Now in pushDetailViewController you add a link to the union of two objects
if (!self.detailViewController) { self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; } [self.detailViewController.mVc = self]; // New line [self.navigationController pushViewController:self.detailViewController animated:YES];
Then in the DetailViewController you reference the object
-(IBAction)nextItem{ [self.mVc pushDetailViewController:[NSIndexPath indexPathForRow:0 inSection:0]]; }
I think that another problem you encountered was distributing a new version of mVC every time you click the nextItem button. IOS will happily allow you to create many MasterViewController objects and create a new one each time you alloc it. You just wanted to get the handle of your original MasterViewController.
Another approach would be to study the parent methods to reference the MasterViewController. But I wanted to show you how to do this with an explicit property, as I thought it would be clearer.
Also, this may or may not fix all your problems, but hopefully at least will show you how to access the actual MasterViewController.
source share