'+entityForName: nil is not a legal NSManagedObjectContext parameter - Core Data

后端 未结 8 701
梦如初夏
梦如初夏 2020-11-28 22:26

I have added all of the relevant code to the App Delegate, and I am able to add to the data model and fetch from the data model in applicationDidFinishLaunchingWithOptions.<

相关标签:
8条回答
  • 2020-11-28 23:03

    In my case the .xcdatamodeld was mislabeled in the AppDelegate:

     let container = NSPersistentContainer(name: "name of data model")
    
    0 讨论(0)
  • 2020-11-28 23:09

    If the destination view controller is embedded in a NavigationController, the context needs to be set appropriately as follows-

      self.mydetailViewController = [[[segue destinationViewController] viewControllers] objectAtIndex:0];
     [self.mydetailViewController setManagedObjectContext:self.managedObjectContext];
    
    0 讨论(0)
提交回复
热议问题