如何从iphone中删除coredata [英] how do i remove coredata from iphone

查看:133
本文介绍了如何从iphone中删除coredata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您更改实体结构时,您知道如何在iPhone模拟器上重置coredata商店吗?

You know how you can Reset the coredata store on an iPhone simulator when you've changed your entity structure?

当我创建一个新版本的核心数据存储时,我需要执行类似的过程,这与我上次在我的iPhone上运行的不同吗?

Do I need to perform a similar process when I've created a new version of my core data store that is different from what I last ran on my iPhone? If so, how, please?

感谢

推荐答案

方便,直到你编写一个方法来删除持久存储通过你的应用程序,你可以只是删除手机上的应用程序。 (在主屏幕上按住手指,直到图标变得摇摆,然后点击应用程序上的x。)然后将手机连接到Mac,选择产品>在XCode中运行,它将在手机上重新安装应用程序,但是空数据目录。

Just for convenience, until you code a way to remove the persistent store through your app, you can just delete the app off the phone. (Hold your finger on the home screen until icons get wiggly, then click the x on your app.) Then with your phone connected to your Mac, choose Product > Run in XCode and it will reinstall your app on the phone, but with empty data directories.

对于部署,当然,您需要提出一种方法,而不删除应用程序,如果你将在部署后更改您的数据模型(假设你会)。数据迁移是最好的选择,但如果所有其他失败,删除持久存储文件。在这样做之前,最好提示用户的批准。如果他们有重要的数据,他们可以拒绝,也许得到旧版本的应用程序回来查看数据和手动迁移,或者他们可以等到你发布版本2.0.1,修复您的数据迁移错误。

For deployment, of course, you need to come up with a way to do it without deleting the app, if you will ever change your data model after deployment (assume you will). Data migration is the best option, but if all else fails delete the persistent store file. It would be preferable to prompt for the user's approval before doing that. If they have important data they can decline and maybe get the old version of your app back to view the data and migrate it by hand, or they can wait until you release version 2.0.1 that fixes your data migration bug.

这篇关于如何从iphone中删除coredata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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