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.
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.
A human-readable description of the object.
DeclarationSwift
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.
DeclarationSwift
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.
DeclarationSwift
@objc
open subscript(key: String) -> Any? { get set }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4