简体   繁体   English

使用 CloudKit 进行轻量级 CoreData 迁移

[英]Lightweight CoreData Migration with CloudKit

Does Core Data handle simple data-model additions like a new attribute w/out any further "help" from me? Core Data 是否可以处理简单的数据模型添加,例如没有我进一步“帮助”的新属性? In my case, I have an app that uses Core Data for varius things related to a users profile.就我而言,我有一个应用程序使用 Core Data 来处理与用户个人资料相关的各种事情。 I have an existing data-model entity called Profile that I want to add 2 new attributes to:我有一个名为 Profile 的现有数据模型实体,我想将 2 个新属性添加到:

hasPublished: Boolean

lastDetail: String

So, does this cover my case?那么,这是否涵盖了我的情况? I'm not re-naming anything, just adding.我没有重新命名任何东西,只是添加。

One more caveat, I'm using a NSPersistentCloudKitContainer as info can be shared across the users devices.还有一点需要注意的是,我正在使用 NSPersistentCloudKitContainer 作为信息可以在用户设备之间共享。

Yes it can handle, but there is some little work from your side.是的,它可以处理,但你这边有一些工作要做。

  1. You need to create new version of Core Data model.您需要创建新版本的 Core Data model。
  2. Call initializeCloudKitSchema() so changes are uploaded to CloudKit.调用initializeCloudKitSchema()以便将更改上传到 CloudKit。
  3. Don't forget to deploy changes to production from CloudKit dashboard.不要忘记从 CloudKit 仪表板将更改部署到生产环境。
  4. Remove initializeCloudKitSchema() when deploying your app to AppStore.将应用部署到 AppStore 时删除initializeCloudKitSchema()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM