Note that there are some explanatory texts on larger screens.

plurals
  1. POHandle CoreData not in RootViewController(migration of vanilla coredata-project)
    primarykey
    data
    text
    <p>First, I'm really new to CoreData.</p> <p>Now I've created a vanilla CoreData-project and have copied all the code to my project in which I want to implement CoreData.</p> <p>In the CoreData-vanilla project, the first viewcontroller(MasterViewController), is the controller who handles the managedObjectContext:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController; BilderViewController *controller = (BilderViewController *)navigationController.topViewController; controller.managedObjectContext = self.managedObjectContext; return YES; } </code></pre> <p>But I want my second ViewController, to handle CoreData:</p> <p><img src="https://i.stack.imgur.com/G0gUO.png" alt="enter image description here"></p> <p>As you see here, I want the "Bilder"-Viewcontroller to handle/use Core Data. Every method is in that controller, so it should work. I've already tried to change the method to:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. BilderViewController *controller = [[BilderViewController alloc] init]; controller.managedObjectContext = self.managedObjectContext; return YES; } </code></pre> <p>But than, I receive the error:</p> <blockquote> <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Event''</p> </blockquote> <p>My managedObjectContext-method:</p> <pre><code>// Returns the managed object context for the application. // If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. - (NSManagedObjectContext *)managedObjectContext { if (_managedObjectContext != nil) { return _managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { _managedObjectContext = [[NSManagedObjectContext alloc] init]; [_managedObjectContext setPersistentStoreCoordinator:coordinator]; } return _managedObjectContext; } </code></pre> <p>How can I fix this?</p> <p>Btw: Eventually, somebody also knows, why the prototype-cell isn't at the top of my tableview. Thx.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload