AndaluZ AndaluZ - 1 month ago 7
Objective-C Question

How to add property in RLMObject which Realm ignores?

I want to add a property of type boolean in a derived RLMObject which is only needed during runtime. So it's not part of the database table. Is there a way to mark the property as not part of the table in Realm?

The reason I need this, is because I want to save the selected state of a uitablecell during runtime. This means, I don't need an extra field in the database table.

I hope my question is clear, thank you.

Answer

I think you will want to use ignored properties of Realm:

edit: included the Swift docs link, but the question is about 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.