I am making an app which has an user input form in it. Now using storyboard, when I set the ViewController which has the form on it as it's initial View Controller and setting the rootViewController in the APp Delegate, I get to save the data with out worries.
When I want to launch the app into another ViewController and have a button link to the input form, I can fill in the form, but when I press save, it tells me that it cannot find the Entity in question.
The Code below is from the appDelegate.m file and the moment it set to the VC that handles the data input. I want to set it so that the ViewController, which is currently commented out becomes the root and then when I save the button on the AddDataVC that it can find the Entity.
I am pretty certain my CoreData code is fine as it is able to save data, but it only crashes when the input form is not the initial ViewController.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
AddDataVC *addDataVC = (AddDataVC *)self.window.rootViewController;
addDataVC.managedObjectContext = self.managedObjectContext;
//ViewController *controller = (ViewController *)self.window.rootViewController;
//controller.managedObjectContext = self.managedObjectContext;
return YES;
}
Thanks in advance:-)
--EDIT--
Below I have pasted the error from the console:
2012-05-17 23:46:37.288 SW_Vault[26604:15203] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Product''
--EDIT 2--
Ok so what I am trying to explain is this. When I use a template like the utility app it allows me to create the Entity and set up a textField and a Save Button and it saves the data just fine. The image is off the storyboard. Notice how there is only 1 VC and it is the initial View:
But when I have another VC as the initial View Controller then it comes up with the error that the entity cannot be found. Which is the error I described above.
Now the code for the Entry View has not changed, but if you look at the first -(BOOL) I posted in this question I can choose between 2 rootViewControllers, I just have to comment one out to use the other.
Now in the second image, if I make the the second VC in that board the initial VC then I do not have a problem, it is only when I get there via a Segue.
I hope that makes more sense:-)