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

  • SEARCH
  • Home
  • 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 972417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:07:18+00:00 2026-05-16T03:07:18+00:00

I may just be passing data between views completely wrong here, so I am

  • 0

I may just be passing data between views completely wrong here, so I am open to completely changing how I pass my data back and forth.

My app delegate creates the NSManagedObjectContext and passes that to my main menu using a UINavigationController which makes it the root view:

MainMenuViewController *mainMenuViewController = [[MainMenuViewController alloc] init];

NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
    // Handle the error.
}
// Pass the managed object context to the view controller.
mainMenuViewController.managedObjectContext = context;

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:mainMenuViewController];
self.theNavController = aNavigationController;

[[self theNavController] setNavigationBarHidden:YES animated:NO];

[window addSubview:theNavController.view];
[window makeKeyAndVisible];

[mainMenuViewController release];
[aNavigationController release];

Then when they select a different view controller from the main menu, I initialize the new view controller, pass the NSManagedObjectContext to it, then push it onto the UINavigationController:

BombsViewController *bombsViewController = [[BombsViewController alloc] init];
bombsViewController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:bombsViewController animated:YES];
[bombsViewController release];

All is fine until I decide to go back to the main menu from my BombsViewController. I am attempting to use the following to pop the root view controller back onto the UINavigationController:

[self.navigationController popToRootViewControllerAnimated:YES];

However, I can’t see a way to send the root view controller my NSManagedObjectContext back since the popToRootViewControllerAnimated method doesn’t accept a view. I tried using the popToViewController:animated: method but then the app crashes with a “terminate called after throwing an instance of ‘NSException’“, “Program received signal: “SIGABRT”.“:

MainMenuViewController *mainMenuViewController = [[MainMenuViewController alloc] init];
mainMenuViewController.managedObjectContext = self.managedObjectContext;
[self.navigationController popToViewController:mainMenuViewController animated:YES];
[mainMenuViewController release];
  • 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-16T03:07:18+00:00Added an answer on May 16, 2026 at 3:07 am

    Why would you send it back? Your root view controller has not been -dealloc‘ed so it still exists in memory and still has a reference to the NSManagedObjectContext. There is nothing to pass back.

    The error you are getting is not Core Data related. Run it in the debugger and set a breakpoint on objc_exception_throw and see where it is crashing.

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

Sidebar

Related Questions

I may just be missing a key concept here. I understand the 'dumb' data
I may just be doing something wrong but all of my javascript files as
I see answers to similar questions and I'm sure I may just not be
I'm trying to implement the Send button , but running into what may just
I'm a bit confused by the Lucene.NET API, but, it may just be a
I fear this just may not be possible, but I'm trying to create a
I just started to use doxygen and may not be familiar with all available
I just realized a function may be defined inside another function in C: void
I just realized that i may not be following best practices in regards to
This may be a stupid question but im just starting to learn Rail thats

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.