In my storyboard, i have two UIViewControllers both using the class CustomViewController.
From the viewDidLoad function of CustomViewController.m, how can I determine which UIViewController in my storyboard is calling this class? For example:
- (void)viewDidLoad
{
if(CALLED_FROM_VC1_IN_STORYBOARD)
{
// load from data feed 1
}
else
{
// load from data feed 2
}
}
What should I replace CALLED_FROM_VC1_IN_STORYBOARD with?
You need to use the
prepareForSegue:sendermethod on the first VC to pass the data along to a property on your second VC.Though you probably don’t want to keep the entire VC in memory, so maybe refactor that to just the bare data. Even if you have to pass along every property!
viewDidLoad is generally called after prepareForSegue, but beware that UIPopovers are an exception.