Tab bar application with UINavigation Controller MOC not being retained.
Posted
by iamsmug
on Stack Overflow
See other posts from Stack Overflow
or by iamsmug
Published on 2010-04-05T19:50:39Z
Indexed on
2010/04/05
19:53 UTC
Read the original article
Hit count: 251
I created a tab bar application from the template and added a navigation controller to one of the tabs. I have already created this app from the navigation app template already and is working. The reason I am doing it this way is because I need to add a tab bar and thought it would be easier starting by using the tab bar project template and adding the nav controller to it rather than the other way round.
I have copied the data model over from the other project and added the relevant code to where it should be.
The problem I am having is passing the moc from the app delegate to the tab with the nav controller on. Here is a snippet from my applicationDidFinishLaunching method in my app delegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self createEditableCopyOfDatabaseIfNeeded];
Top_BananaTableViewController *top_BananaTableViewController = (Top_BananaTableViewController *)[navigationController topViewController];
top_BananaTableViewController.managedObjectContext = self.managedObjectContext;
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
Everything seems fine here but when it comes to the fetchedResultsController on my nav controller view it bombs out with:
'+entityForName: could not locate an NSManagedObjectModel for entity name 'cards''
When I checked what was set to my managedObjectContext on that view it was null.
I don't know why or where it is loosing it's setting.
Please help.
© Stack Overflow or respective owner