简体   繁体   English

我应该在iOS上的Realm中删除旧表吗?

[英]Should I delete old tables from Realm on iOS?

As part of an update, I retired a class that was persisted to Realm. 作为更新的一部分,我淘汰了一个持久化到Realm的类。 These objects could potentially take up a lot of space on users' devices, so I don't want the old objects' data to remain in the Realm file after the migration. 这些对象可能会占用用户设备上的大量空间,因此我不希望迁移后旧对象的数据保留在Realm文件中。 Will the Realm migration detect that the class is no longer in the project and do some cleanup, or do I need to explicitly delete that table? Realm迁移是否会检测到该类不再存在于项目中并进行一些清理,还是我需要显式删除该表? In the latter case, how do I do that? 在后一种情况下,我该怎么做?

You need to explicitly delete all of the data for the type from the Realm file during the migration. 在迁移期间,您需要从Realm文件中显式删除该类型的所有数据。 You can do so by calling Migration.deleteData(forType:) within your migration block. 您可以通过在迁移块中调用Migration.deleteData(forType:)实现。

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

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