Apple 的 CoreDataBooks 示例存在问题
我目前正在使用 CoreData,并且对 Apple 的 CoreDataBooks 示例有疑问。
基本上我只是想扩展数据模型。我也更新了模型类,没有编译器错误,但当我想启动示例时发生崩溃。
未解决的错误错误域=NSCocoaErrorDomain代码=134130 UserInfo=0x1316ce0“操作无法完成。(Cocoa错误134130。)”,{ URL = 文件://localhost/.../CoreDataBooks.sqlite; ……一些废话信息…… Reason = "找不到源商店的模型"; ?
我需要更新 sqlite 数据库吗
谢谢
I am currently playing with CoreData and have a problem with the CoreDataBooks Example from Apple.
Basically I just wanted to extend the data model. I updated the model class aswell and no compiler error, butr a crash when I want to start the example.
Unresolved error Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0x1316ce0 "Operation could not be completed. (Cocoa error 134130.)", {
URL = file://localhost/.../CoreDataBooks.sqlite;
...some nonsense info ...
reason = "Can't find model for source store";
}
Do I need to updat the sqlite database ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当您修改或更新数据模型时,请确保:
为任何新的或修改的实体添加
NSManagedObject
类标头和实现(在数据建模器中选择实体并使用New File ... > NSManagedObject
创建新的类文件)。在重建和重新安装之前,从 iPhone 模拟器或设备中删除您的应用。您可以稍后再担心迁移问题。
Whenever you modify or update the data model, make sure you:
Add
NSManagedObject
class header and implementations for any new or modified entities (select the entity in the data modeler and useNew File... > NSManagedObject
to create new class files).Delete your app from the iPhone simulator or device, before rebuilding and reinstalling. You can worry about migration issues later.
无论如何,我需要在更改任何内容之前对数据模型进行版本控制,以确保模型自动迁移。
Anyway, I needed to version the datamodel before changing anything that would ensure that the model does migrate automatically.