TazmanNZL
TazmanNZL

Reputation: 392

Passing managed object from app delegate to a VC that is not RootVC

I have a Navigation Controller who's initial view is a View Controller with a button that does a push segue to a tableviewcontroller. I'm wanting to pass the managed object context from the appdelegate to the tableviewcontroller.

I'm using a storyboard with a layout like so:

(Navigation Controller > ViewController) > TableviewController

I tried referencing the tableviewcontroller by using the array of view controllers held in the navigation controller. But the navigation controller is only saying it has 1 VC. (not 2)

Do I first have to pass it to the initial VC and then pass it from the initial VC to the tableVC using prepare for segue?

What is the most practical way of passing the managed object context from the app delegate to a view controller that is not the root view controller? I just can't figure it out.

Upvotes: 0

Views: 125

Answers (1)

Tarek Hallak
Tarek Hallak

Reputation: 18470

If your AppDelegate has a reference to this 'Navigation Controller' the you can use:

MyAppDelegate *appDelegate= (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 
appDelegate.navigation.tableObject = ..

otherwise you need to pass that vc from your navigation down to your UITableviewController.

Upvotes: 0

Related Questions