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

后端 未结 8 713
梦如初夏
梦如初夏 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 22:53

    If you are using segues you will get the same problems if you don't pass the context down the line. Use this code in the prepareForSegue method of class initiating the segue:

    [[segue destinationViewController] setManagedObjectContext:self.managedObjectContext];
    

    That assumes you hold your context in a property called "managedObjectContext" of course.

提交回复
热议问题