extension AsymmetricObject


  • Creates an unmanaged instance of a Realm object.

    The value argument is used to populate the object. It can be a key-value coding compliant object, an array or dictionary returned from the methods in NSJSONSerialization, or an Array containing one element for each managed property. An exception will be thrown if any required properties are not present and those properties were not defined with default values.

    When passing in an Array as the value argument, all properties must be present, valid and in the same order as the properties defined in the model.



    public convenience init(value: Any)



    The value used to populate the object.


Object Customization

  • Override this method to specify a map of public-private property names. This will set a different persisted property name on the Realm, and allows using the public name for any operation with the property. (Ex: Queries, Sorting, …). This very helpful if you need to map property names from your Device Sync JSON schema to local property names.

    class Person: AsymmetricObject {
        @Persisted var firstName: String
        @Persisted var birthDate: Date
        @Persisted var age: Int
        override class public func propertiesMapping() -> [String : String] {
            ["firstName": "first_name",
             "birthDate": "birth_date"]


    Only property that have a different column name have to be added to the properties mapping dictionary.



    open override class func propertiesMapping() -> [String : String]

    Return Value

    A dictionary of public-private property names.

Key-Value Coding & Subscripting

  • Returns or sets the value of the property with the given name.



    open subscript(key: String) -> Any? { get set }