AndaluZ
AndaluZ

Reputation: 1526

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.

Upvotes: 1

Views: 591

Answers (2)

Antwan van Houdt
Antwan van Houdt

Reputation: 6991

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.

Upvotes: 2

Alex Shutov
Alex Shutov

Reputation: 3282

Realm is noSql database so it has no tables - it stores graph of dependencies. That is why you can just create separate 'settings' class, include it in your realm module (@RealmModule) and store single instance of it in realm file for that module. This will be the single instance of that object in database.

Upvotes: 1

Related Questions