How to create the magic .xcdatamodeld folder / package?

后端 未结 2 1851
臣服心动
臣服心动 2020-12-14 11:09

Recently, I managed (by accident, don\'t ask) to delete my Core Data datamodel files and classes. And I was completely and utterly unable to create the files again to be exa

2条回答
  •  春和景丽
    2020-12-14 11:29

    the coredata model bundle keeps all your model versions. The model with the green checkmark is the current version, data stored into coredata will be saved using this scheme. All other datamodel versions are there to support database migration, data stored in a different version can be upgraded automatically if there are only small changes in the data model.

    To create a model bundle you select the single model, open the Design menu in the mainmenu and select Data Model and Add Model Version.

    Your app is crashing because it expects a datamodel bundle with the type momd.

    NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"foobar" ofType:@"momd"];
    

    If you have only one Datamodel it is not compiled into a "momd"-file. But I forgot the actual extension.


    In Xcode4 Add Model Version can be found within the Editor main menu.

提交回复
热议问题