为什么扩展名是“momd”但不是“xcdatamodel”当搜索模型文件的路径时 [英] Why the Extension is "momd" but not "xcdatamodel" when search the path for the Model file

查看:105
本文介绍了为什么扩展名是“momd”但不是“xcdatamodel”当搜索模型文件的路径时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Core Data创建了主详细信息应用程序。有一个简单的代码
获取模型文件的路径:

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"];

我不知道为什么扩展不是xcdatamodel,而是momd。

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

有人知道答案吗?

推荐答案

$ c> mom 和 momd 文件是 xcdatamodel xcdatamodeld 文件。

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

有关编译过程如何工作的信息这里。引用文档:

There information about how the compiling process works here. To quote from the docs:


数据模型是一种部署资源。除了模型中的实体和属性的详细信息之外,在Xcode中创建的模型还包含有关图的信息 - 它的布局,元素的颜色等。后面的信息在运行时不需要。使用模型编译器 momc 编译模型文件,以删除无关的信息,并使资源的运行时加载尽可能高效。

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.

这篇关于为什么扩展名是“momd”但不是“xcdatamodel”当搜索模型文件的路径时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆