加载到CoreData
我创建了一个基于窗口的应用程序,其中包含 coredata 框架。我编辑了 xcdatamodel,创建了一个新实体,定义了属性并生成了托管对象类文件。当我现在尝试运行我的应用程序时,我的应用程序在模拟器中崩溃并出现以下错误:用于打开商店的模型与用于创建商店的模型不兼容”;我的项目中没有 sqlite 数据库。现在我的问题是如何将数据添加到 coredata 并消除此错误!我了解 coredata 带有在运行时生成的自己的数据库,我如何访问它?
I have created a window based application with the coredata framework included. I have edited my xcdatamodel, created a new entity, defined attributes and generated the managed object class file. When I now try to run my application, my app crashes in the simulator with this error: The model used to open the store is incompatible with the one used to create the store"; I have no sqlite db in my project. Now my question is how to add data to coredata and get rid of this error! i understand coredata comes with its own db generated at runtime, how can I access that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要消除此错误:
- 启动 iPhone 模拟器
- 单击应用程序并按住鼠标按钮几秒钟即可卸载该应用程序(就像卸载 iPhone 上的应用程序一样)
- 重新安装+从 XCode 再次运行应用程序
每当您更改数据模型中的某些内容(添加属性/实体等)时,您都会收到此错误。如果您想知道如何在更改数据模型时保留数据,您应该搜索“CoreData versioning”。
To get rid of this error:
- start the iPhone simulator
- un-install the app by clicking it and holding the mouse button for a few seconds (just like you would uninstall an app on your iPhone)
- re-install + run the app again from XCode
You get this error whenever you changed something in your data model (added attributes / entities etc.). If you want to know how to keep your data when changing the data model, you should google for "CoreData versioning".