Been having my first crack at Core Data and I\'m getting the following error when running my code on my device, but it works fine on the simulator..
*
I have been looking an answer for hours and nothing worked. But then I suddenly found this article. So according to this, the problem was in setting root controller in this part of AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
ListViewController *rootView = (ListViewController *)self.window.rootViewController;
rootView.managedObjectContext = self.managedObjectContext;
return YES;
}
In fact you should define what root controller will delegate your CoreData connection. And in my case I had a TabBarController connected to other views, so my targed view root controller was defined as TabBar and it caused an error. I changed
ListViewController *rootView = (ListViewController *)self.window.rootViewController;
to
ListViewController *rootView = (ListViewController *)self.window.superview;
and everything worked.