Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5957295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:22:50+00:00 2026-05-22T18:22:50+00:00

I’ve been reading this thread on Stackoverflow and have been trying to replicate the

  • 0

I’ve been reading this thread on Stackoverflow and have been trying to replicate the solution with no success in my own project.

My project has 4 tabs. In my app delegate I do this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    


    Page1 *page1 = (Page1 *)[navController topViewController];
    Page2 *page2 = (Page2 *)[navController topViewController];
    Page3 *page3 = (Page3 *)[navController topViewController];
    Page4 *page4 = (Page4 *)[navController topViewController];

    page1.managedObjectContext = self.managedObjectContext;
    page2.managedObjectContext = self.managedObjectContext;
    page3.managedObjectContext = self.managedObjectContext;
    page4.managedObjectContext = self.managedObjectContext;


    [self.window makeKeyAndVisible];

    return YES;
}

In the originating thread it says I need to create a IBOutlet to each navController for each tab I want to use Core data on.

Whilst you can assign multiple delegates for the UINavigationController the same is not true for the outlets, you can only ever supply ONE outlet for the navController.

I can get Page1 to work, but the other pages simply crash; because of the lack of an IBOutlet.

Do I really need X IBOutlets for Y Tabs or can I do it another way?

Another issue is that the originating thread the accepted answer is:

Ideally you want to pass either the
NSManagedObjectContext,
NSFetchedResultsController or the
relevant NSManagedObject “down” into
the UIViewController.

But there is no code or example of how to do this.

Ideally, I do not want to use a singelton or use the app delegate all over the place.

Any confirmation and clarification would be great.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:22:50+00:00Added an answer on May 22, 2026 at 6:22 pm

    Your immediate problem has nothing to do with Core Data. You are assigning the same navigation controller to each tab when you need a separate navigation controller for each tab otherwise the navigation controller’s hierarchy of views will get scrambled every time you change tabs.

    The pattern recommended in the question you linked to is called “dependency injection” and it is the one that Apple recommends in most cases. However, in the case of tabbars or any other complex view/view-controller hierarchy, dependency injection can get to complicated. It’s a particular issue with tabbars because you don’t usually load all tab view/view-controllers when the app starts but wait until each tab is selected before loading its elements.

    Instead, you can use an alternative pattern that exploits the UIApplication objects singleton status. Since there is only one application object, there is only one application delegate object. That means that anywhere in the app you can make a call like this:

    (MyApplicationDelegate *) appDelegate=(MyApplicationDelegate *)[[UIApplication sharedApplication] delegate];
    

    … and always get the same application object. Then, if you have the managed object context defined as a property of the app delegate you can get the context just by:

    theManagedObjectContext=appDelegate.managedObjectContext
    

    Add these two lines to every view controller and you can always be sure of getting the app delegate’s managed object context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.