iPhone |从头开始构建的新版本的核心数据迁移 [英] iPhone | Core data migration for a new version built from scratch

查看:116
本文介绍了iPhone |从头开始构建的新版本的核心数据迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序更新,这个版本是从头开始构建的,并且具有全新的 coreData 模式模式。我需要从旧模型中写入 coreData 迁移。我一直在寻找资源写 coreData 迁移,但他们都需要旧的模型文件。由于这个版本是全新的,我没有旧的模型模式。

I am working on an App update and this version is completely built from scratch and has completely new coreData model schema. I need to write coreData migration from the older model. I have been looking at resources to write coreData migration but all of them need old model file. Since this version is completely new, I don't have the old model schema.

有什么方法我可以写迁移,使其转储旧模型,当用户更新应用?

Is there any way I can write the migration such that it dumps the old model when user updates the app?

提前感谢

推荐答案

旧的应用程序,那么您可以从包含在应用程序包中的编译的模型文件中重建模型:

If you have the old App, then you can recreate the model from the compiled model file which is contained in the App bundle:


  • 将应用程序同步到iTunes

  • Ctrl - 点击iTunes中的应用程序,然后使用在Finder中显示查找YourApp.ipa文件。

  • 将YourApp.ipa复制到临时目录,并在命令行上使用unzip YourApp.ipa解压缩归档。

  • 在解压缩的Payload / YourApp.app 文件夹中应该有一个XXX.momd文件夹,其中包含文件XXX.mom( XXX 是模型的名称)。这是已编译的模型文件。

  • 在您的Xcode项目(或临时项目)中,创建一个新的数据模型文件XXX.xcdatamodeld。

  • 选择此文件,然后从菜单中选择编辑器 - >导入...。

  • 在导入对话框中,从上面选择XXX.mom / li>
  • Sync the App to iTunes, if necessary.
  • Ctrl-Click on the App in iTunes, and use "Show in Finder" to locate the "YourApp.ipa" file.
  • Copy "YourApp.ipa" to a temporary directory, and use "unzip YourApp.ipa" on the command line to extract the archive.
  • In the extracted "Payload/YourApp.app" folder there should be a "XXX.momd" folder containing a file "XXX.mom" (XXX is the name of the model). This is the compiled model file.
  • In your Xcode project (or a temporary project), create a new "Data Model" file "XXX.xcdatamodeld".
  • Select this file and choose "Editor -> Import ..." from the menu.
  • In the import dialog, choose the "XXX.mom" file from above.

这篇关于iPhone |从头开始构建的新版本的核心数据迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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