CustomEventRepresentable

@objc(RLMCustomEventRepresentable)
public protocol CustomEventRepresentable

A type which has a custom representation in Realm events.

By default, objects are serialized to JSON using built-in rules which include every property. If you wish to customize how a class is serialized in events, you can declare it as conforming to this protocol and define customEventRepresentation().

  • Get the custom event serialization for this object.

    This function must return a valid JSON String, as this is included in a larger JSON document. Implementations of this function should be “pure” and access no data other than that which is obtainable from the Object it is called on, and it should not mutate the object which it is called on. This function is called on a background thread in a somewhat unusual context, and attempting to access other data is likely to cause problems.

    Declaration

    Swift

    @objc
    func customEventRepresentation() -> String