Is there a way to convert/serialize data before data is stored into a local realm (and after data is extracted from the realm)?

Is there a way to convert data that goes into/out of the realm? I ask because I have a some data models that have data types that are not acceptable relam data types (e.g. or Swift URL). This is easy to convert to/from Strings, but I haven’t found a way to do so, thus my data models use strings for storage and do conversions to/from Uri/URL as the public api (so there’s a bunch of boilerplate conversion code that happens at runtime (yuck).

Sounds like it may be a good fit for New article – Realm-Swift Type Projections

and the Swift Docs Type Projection

You can also cast your objects to Data() and/or an encoded string which is supported.

let attrString = //some attributed string
let data = try NSKeyedArchiver.archivedData(withRootObject: attrString, requiringSecureCoding: false)
//store data in Realm
let dataString = data.base64EncodedString()
// store dataString in Realm

This is cool. But does it exist for android as well?

Er, i meant: is this available in the java SDK in some fashion? Thanks.

@Alex_Tang1: Sorry, we don’t that feature available on Android SDK.