Core Data - 在向xcddatamodel文件添加额外属性后,应用程序崩溃 [英] Core Data - Application crashes after adding extra attributes to xcddatamodel file

查看:207
本文介绍了Core Data - 在向xcddatamodel文件添加额外属性后,应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用核心数据。对于数据,我链接sqlite文件与它。我的所有数据都获取成功,我得到正确的结果。当我向核心数据实体添加一些属性,然后运行应用程序时,它会崩溃。

I am using core data in my application. For data I link the sqlite file with it. All of my data is fetched successfully and I get the proper results. When I add some more attributes to the core data entity and then run the application then it crashes.

我的错误消息:
用于打开store与用于创建商店的库不兼容

My error message: "The model used to open the store is incompatible with the one used to create the store"

所以可能是因为我改变了数据模型。现在我应该做什么,如果我想添加一些额外的字段在我的coredata模型没有应用程序崩溃?

So may be it seem because i have changed the Data model. Now what should i have to do if i want to add some extra fields in to my coredata model without the application crashing?

推荐答案

崩溃的原因是因为您的应用程序的数据模型不一致。事实上,你应该得到一个非常相似的错误信息。

The reason it crashes is because your app's data model is inconsistent. In fact you should be getting an error message very similar to that.

你可以做什么来解决它是从模拟器或手机删除你的应用程序,然后简单地重建和重新运行从Xcode。

What you can do to fix it is the delete your app off of the simulator or phone, and then simply rebuild and rerun from xcode.

此外,为了避免将来出现此问题,您可以配置核心数据以查找并接受数据模型的扩展,尽管我还没有实现这一点。不能告诉你如何做到这一点。有些在线搜索应该会产生正确的例子。

Additionally, to avoid this problem in the future, you can configure core data to look for, and accept extensions of your data model, though I have not implemented this so I couldn't tell you how to do it exactly. Some searching online should yield a correct example.

这篇关于Core Data - 在向xcddatamodel文件添加额外属性后,应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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