如何从realm文件中删除一个类 [英] How to delete a class from realm file

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

问题描述

我的默认Realm有几个类。我想完全删除所有引用并删除其中一个类的所有数据。我怎样才能做到这一点?当我从我的应用程序中删除该类时,在Realm Browser中打开文件时仍会列出该类。

My default Realm has several classes. I want to completely remove all references and delete all data for one of the classes. How can I do this? When I remove the class from my application, the class is still listed when I open the file in Realm Browser.

推荐答案

完全从您的Realm文件中删除一个类,您要做两件事:

To completely remove a class from your Realm file you'll want to do two things:


  1. 从您的应用程序中删除该类。

  2. 您的迁移阻止调用 Migration.deleteData(_:) 从领域中删除对该类的所有引用。

  1. Remove the class from your application.
  2. Have your migration block call Migration.deleteData(_:) to remove all references to the class from the Realm.

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

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