I'm new to Realm, I used to use MagicalRecord before.
In MagicalRecord, I can handle import function or even set some mappingKeys for multiple candidate names.
I would like to customize some of the properties of my Realm object.
I found DynamicObject that looks like what I want. However, I have no idea how to use it.
To customize your getters and setters with Realm Swift, you will need to define a plain underlying stored property. You can then access this property from another you define on top of that with custom setters and getters as seen below.
Note that using Swift's
willSetordidSetwith Realm Swift might not work like you expect. They are only triggered for unattached standalone objects. Once you persist an object or retrieve a persisted obejct, all getters and setters are overridden to directly access the persisted values.DynamicObjectis not what you want to use. This is intended for use-cases, where you don't have strong guarantees over your object schema and need to deal with either unstructured data or databases you didn't created yourself.