RealmProperty

public final class RealmProperty<Value> : RLMSwiftValueStorage where Value : RealmPropertyType
extension RealmProperty: Equatable where Value: Equatable
extension RealmProperty: Codable where Value: Codable

RealmProperty实例表示支持类型的多态值。

要更改RealmProperty实例存储的基础值,请更改该实例的value属性。

注意

RealmProperty不应在 Realm 对象上声明为@objc dynamic 。 请改用let
  • 用于获取/设置基础值。

    • 用法: class MyObject: Object { let myAnyValue = RealmProperty<AnyRealmValue>() } // Setting myObject.myAnyValue.value = .string("hello") // Getting if case let .string(s) = myObject.myAnyValue.value { print(s) // Prints 'Hello' }

    声明

    迅速

    public var value: Value { get set }

适用于以下位置: ValueEquatable

适用于以下位置: ValueCodable