当我更改数据模型时,我的应用程序崩溃了。为了再次运行它我应该从模拟器中删除应用程序并运行它。除了这样做之外,我们可以运行应用程序,而无需在每次更改数据模型时删除。我想要使用以前的数据。提前致谢
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:
删除 {* 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
更多推荐
应用程序由于数据模型的更改而崩溃
发布评论