Core Data model files does not load on rename

前端 未结 6 1071
眼角桃花
眼角桃花 2020-12-29 09:52

I have a model file thats named \"Model\". If I rename it to \"SomeOtherName\" it just does not get loaded.

initWithContentsOfURL returns nil and:

6条回答
  •  被撕碎了的回忆
    2020-12-29 10:38

    This worked for me:

    1. Click on your YourName.xcdatamodel
    2. Right Click on it to show file inspector
    3. On the right you can see "Target Membership", there should be a checkmark.

    (Check if the name in AppDelegate is the same as your xcdatamodel file. -> let container = NSPersistentContainer(name: "YourName") ......)

提交回复
热议问题