Why the Extension is "momd" but not "xcdatamodel" when search the path for the Model file

IosCore Data

Ios Problem Overview


I create a Master-Detail application using Core Data. And there is a simple code to get the path for Model file:

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Model" withExtension:@"momd"];

I have no idea why the extension isn't "xcdatamodel" but "momd".

Does anyone know the answer?

Ios Solutions


Solution 1 - Ios

The mom and momd files are compiled versions of xcdatamodel and xcdatamodeld files.

There information about how the compiling process works here (page 31). To quote from the docs:

> A data model is a deployment resource. In addition to details of the entities and properties in the model, a model you create in Xcode contains information about the diagram—its layout, colors of elements, and so on. This latter information is not needed at runtime. The model file is compiled using the model compiler, momc, to remove the extraneous information and make runtime loading of the resource as efficient as possible.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVIRGILView Question on Stackoverflow
Solution 1 - IosAmy WorrallView Answer on Stackoverflow