AsymmetricObject
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 inNSJSONSerialization
, or anArray
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 thevalue
argument, all properties must be present, valid and in the same order as the properties defined in the model.Declaration
Swift
public convenience init(value: Any)
Parameters
value
The value used to populate the object.
-
The object schema which lists the managed properties for the object.
Declaration
Swift
public var objectSchema: ObjectSchema { get }
-
A human-readable description of the object.
Declaration
Swift
open override var description: String { get }
-
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"] } }
Note
Only property that have a different column name have to be added to the properties mapping dictionary.
Declaration
Swift
open override class func propertiesMapping() -> [String : String]
Return Value
A dictionary of public-private property names.
-
Returns or sets the value of the property with the given name.
Declaration
Swift
@objc open subscript(key: String) -> Any? { get set }