Rename xcdatamodel file

前端 未结 10 2130
暖寄归人
暖寄归人 2020-12-05 00:55

What do in need to do to rename the .xcdatamodel file. Renaming .xcdatamodel filename, along with changing ...

NSURL *modelURL = [[NSBundle mainBundle] URLFo         


        
相关标签:
10条回答
  • 2020-12-05 01:37

    This can be done in the following manner: open .xcdatamodeld in XCode. In the inspector panel go to the Identity and Type section. In the Full Path field click on the arrow icon next to the full path. In Finder duplicate the xcdatamodel that you wish to rename. Rename the duplicate to the desired name. Back in Xcode, click on the directory icon next to the Location field. Select the xcdatamodel duplicate that you renamed to the desired name and click Choose. You can delete the old original xcdatamodel if you wish.

    0 讨论(0)
  • 2020-12-05 01:38

    Looks like momd missing in resources files. You can check in generated .app.

    Make sure it is in compile sources build phase.

    And clean/rebuild sometimes helps with xcdatamodels... Especially when creating/renaming them...

    0 讨论(0)
  • 2020-12-05 01:39

    In my case I had a file called Model.xcdatamodeld in my project, I decided renaming it to MyModel.xcdatamodeld through XCode. It did correctly, however the inner file was still called Model.xcdatamodel. I could not rename it through XCode, so I did through my friend Finder. The problem from now on was that Xcode wasn't opening this file anymore. Then what I did was just searching for it on the project.pbxproj and renamed the file name. Now Xcode could open it perfectly.

    1D707FAE1FA9EBAB00A6D123 /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MyModel.xcdatamodel; sourceTree = "<group>"; };
    

    Of course that I also had to rename it on the AppDelegate.

    0 讨论(0)
  • 2020-12-05 01:43

    In Xcode 4.2, I renamed my model (*.xcdatamodeld) file in project navigator (it automatically renamed *.xcdatamodel file inside a package, and both files in my filesystem).

    In initWithContentsOfURL: of the NSManagedObjectModel, I used a new name.

    This resulted in what @Mustafa is describing in the question (nil model).

    So I tried adding a new version of my model and it solved the problem (even though I had no changes in my model).

    0 讨论(0)
提交回复
热议问题