ObjectProxy
@dynamicMemberLookup
public struct ObjectProxy<O> where O : CoreStoreObject
An ObjectProxy
is only used when overriding getters and setters for CoreStoreObject
properties. Custom getters and setters are implemented as a closure that “overrides” the default property getter/setter. The closure receives an ObjectProxy<O>
, which acts as a fast, type-safe KVC interface for CoreStoreObject
. The reason a CoreStoreObject
instance is not passed directly is because the Core Data runtime is not aware of CoreStoreObject
properties’ static typing, and so loading those info every time KVO invokes this accessor method incurs a heavy performance hit (especially in KVO-heavy operations such as ListMonitor
observing.) When accessing the property value from ObjectProxy<O>
, make sure to use ObjectProxy<O>.$property.primitiveValue
instead of ObjectProxy<O>.$property.value
, which would execute the same accessor again recursively.
-
Returns the value for the property identified by a given key.
Declaration
Swift
public subscript<OBase, V>(dynamicMember member: KeyPath<O, FieldContainer<OBase>.Stored<V>>) -> FieldProxy<V> where OBase : CoreStoreObject, V : FieldStorableType { get }
-
Returns the value for the property identified by a given key.
Declaration
Swift
public subscript<OBase, V>(dynamicMember member: KeyPath<O, FieldContainer<OBase>.Virtual<V>>) -> FieldProxy<V> where OBase : CoreStoreObject { get }
-
Returns the value for the property identified by a given key.
Declaration
Swift
public subscript<OBase, V>(dynamicMember member: KeyPath<O, FieldContainer<OBase>.Coded<V>>) -> FieldProxy<V> where OBase : CoreStoreObject { get }