In my project I'm using a tabBarController, then on one of my tabs, I add a navigation controller.
The problem I'm having is this: If I use this code in the AppDelegate:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch
[window addSubview:[rootController view]];
[window makeKeyAndVisible];
return YES; } my tabBar view (which is in the main.xib) comes up, but when I click on the tab for the navigation controller (which开发者_运维问答 is using core data) the app crashes with this error:
NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'HotSprings
So, I found this code for the AppDelegate: - (void)applicationDidFinishLaunching:(UIApplication *)application {
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// Handle the error.
}
RootViewController *rootViewController = (RootViewController *)[navController topViewController];
rootViewController.managedObjectContext = self.managedObjectContext;
[window addSubview:[navController view]];
[window makeKeyAndVisible];
} But, of course, it loads the navigation controller view and ignores main.xib and the tab bar controller.
So, I need to know how to use this last code, but load the tab bar and main.xib. I tried changing the navController to my rootController (which is my tabBarController property, but it doesn't like the "topViewController", which is associated with the navigation controller.
Thanks, Jaime
You need to read the error message more carefully. The error is in your core data entity name, not in your view controller
+entityForName: could not locate an NSManagedObjectModel for entity name 'HotSprings
精彩评论