更改 Core Data 托管对象模型的文件名
如何更改 Core Data 托管对象模型的文件名?
我想更改 Xcode 项目中 Core Data 托管对象模型的文件名。我不担心任何迁移问题。
我目前以这种方式访问代码中的文件:
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Template" ofType:@"momd"];
我还没有找到一种方法来更改 momd 文件名/包,而不会导致 Xcode 无法找到更改后的文件名。
How do you change the filename of a Core Data managed object model?
I would like to change the filename for the Core Data managed object model in my Xcode project. I am not concerned about any migration issues.
I currently access the file in my code this way:
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Template" ofType:@"momd"];
I have not found a way to change the momd filename/package that does not result in Xcode failing to find the changed filename.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
"model".xcdatamodeld
内有一个隐藏文件.xcurrentversion
。只需编辑此文件以匹配您模型的新名称:
You have a hidden file
.xcurrentversion
inside the"model".xcdatamodeld
.Just edit this file to match your model's new name:
这样做了好几次。
只需重命名 xcdmodel 并在从捆绑包加载它时处理该名称即可。在运行之前,请确保清洁目标。 (例如,删除所有预编译文件,否则他认为他已经编译了模型,因此您的应用程序无法加载 momd,因为它们的名称错误)
Done that several times.
Simply rename the xcdmodel and take care of the name when you load it from the bundle. Before you run, make sure to clean the target. (Eg remove all precompiled files, else he think he did compile the model already and thus your app fails to load the momd since they are there with the wrong name)
很确定这就是原因:http://openradar.appspot.com/7500956
Pretty sure this is the cause: http://openradar.appspot.com/7500956