应用程序由于数据模型的更改而崩溃 [英] App Crashed due to change in datamodel

查看:129
本文介绍了应用程序由于数据模型的更改而崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我更改数据模型时,我的应用程序崩溃了。为了再次运行它我应该从模拟器中删除应用程序并运行它。除了这样做之外,我们可以运行应用程序,而无需在每次更改数据模型时删除。我想要使​​用以前的数据。提前致谢

My app is crashing when ever i change the data model. Inorder to run it again i should delete the app from simulator and the run it. Instead of doing this is there any means that we can run the app without deleting whenever we change the datamodel. i want the previous data to be used. Thanks in advance

推荐答案

答案有点棘手,但这对我来说总是有用的。这是为了干净安装新的兼容.sqlite文件,不是迁移

The answer is a bit tricky but this always works for me. This is for a clean installation of a new compatible .sqlite file, not a migration!

启动模拟器,删除应用程序和数据(删除应用程序后弹出窗口)。

launch simulator, delete the app and the data (the popup after you delete the app).

退出模拟器

打开X -Code,在对您的数据模型进行任何编辑后

open X-Code, after making any edits to your data model

如果需要更新datamodel版本:

if needed update the datamodel version:


  1. 编辑器>添加模型版本...

  2. 在出现的对话框中设置您的首选项(最好是计数)

  3. click在{ appname }。xcdatamodeld然后在最右侧的窗格中

  4. 点击最右侧列顶部3个图标的左侧图标

  5. 版本化核心数据模型选择您刚创建的那个

  1. Editor > Add Model Version...
  2. set your prefs in the dialog that appears (counting up is preferable)
  3. click on the {appname}.xcdatamodeld then in the far right pane
  4. click the left icon of the 3 icons on top of the far right column
  5. under Versioned Core Data Model select the one you just created

删除 {* appname *}。sqlite 文件(或备份,从项目文件夹中删除,删除参考)

delete the {*appname*}.sqlite file (or back it up, remove it from project folder, and delete reference)

清理应用程序(产品>清洁

运行应用程序模拟器(对于本教程,我将假设4.2)

Run the app in a simulator (for this tutorial I will assume 4.2)

当模拟器正在运行时,在Finder窗口中,导航到:
{ * home *}>图书馆>应用程序支持> iPhone模拟器> 4.2>应用> {*随机标识符*}>文件> {* appname *}。sqlite

While the simulator is running, in a Finder window, navigate to: {*home*} > Library > Application Support > iPhone Simulator > 4.2 > Applications > {*random identifier*} > Documents > {*appname*}.sqlite

将此文件复制到其他位置

停止在X-Code中运行您的应用程序

Stop running your app in X-Code

将{ appname }。sqlite文件拖放到文件中X-Code中的列表。

Drag and drop the {appname}.sqlite file into the files list in X-Code.

在弹出的对话框中,确保复制到文件夹复选框,已检查。

In the dialog that pops up, make sure the copy to folder checkbox, is checked.

产品>清洁

然后再次在模拟器中运行应用程序

Then run the app in the simulator again

现在你应该有一个工作的sqlite文件!

Now you should have a working sqlite file!

干杯,
Robert

Cheers, Robert

这篇关于应用程序由于数据模型的更改而崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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