简体   繁体   English

是否需要轻量级迁移?

[英]Lightweight Migration Necessary?

I have an existing app. 我有一个现有的应用程序。 I already performed a lightweight migration once, so I'm not totally unfamiliar. 我已经进行了一次轻量级迁移,所以我并不完全陌生。 However, I recently was working on my app and, without thinking, added two new entities without adding a new Core Data model version. 但是,我最近正在使用我的应用程序,不加思索地添加了两个新实体,而没有添加新的Core Data模型版本。

However, when I uploaded the app via Xcode onto my phone and several test users phones, it didn't cause problems. 但是,当我通过Xcode将应用程序上传到我的手机和几位测试用户的手机上时,并没有引起问题。

Is it possible that I don't need to do a lightweight migration? 是否有可能我不需要进行轻量级迁移?

When you set up your app for a lightweight migration, you probably inserted the following lines into your CoreData framework. 在为轻量级迁移设置应用程序时,您可能在CoreData框架中插入了以下几行。 These settings enabled the options that support lightweight migrations (these are from a Swift 3.0 app so they may vary a bit): 这些设置启用了支持轻量级迁移的选项(这些选项来自Swift 3.0应用程序,因此可能有所不同):

NSMigratePersistentStoresAutomaticallyOption as NSObject: true,                 
NSInferMappingModelAutomaticallyOption as NSObject: true 

If you've left these lines in place, then CoreData will continue to perform lightweight migrations correctly when they're required so you should be OK as long as you don't do anything that requires more action on your part - like changing the name of an entity or property. 如果您保留了这些行,那么CoreData将在需要时继续正确执行轻量级迁移,因此只要您不做任何需要更多操作的事情(例如更改名称)就可以了。实体或财产。

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

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