如何在RLMObject中添加Realm忽略的属性



我想在派生的RLMObject中添加一个布尔类型的属性,该属性仅在运行时需要。所以它不是数据库表的一部分。是否有一种方法可以将属性标记为不属于Realm表的一部分?

我需要这个的原因是因为我想在运行时保存一个可用单元格的选择状态。这意味着,我不需要在数据库表中添加额外的字段。

我希望我的问题很清楚,谢谢。

我想你会想使用ignored properties of Realm:

edit:包含Swift文档链接,但问题是关于ObjC的https://realm.io/docs/objc/latest/ignored-properties

Override Object.ignoredProperties() to prevent Realm from persisting model properties. Realm won’t interfere with the regular operation of these properties: they’ll be backed by ivars and you can freely override their setters and getters.

Realm是noSql数据库,所以它没有表-它存储依赖关系图。这就是为什么你可以创建单独的"设置"类,包括它在你的领域模块(@RealmModule)和存储它的单个实例的领域文件为该模块。

最新更新