mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:17 +01:00
add Field.Coded dynamic lookups for ObjectPublisher and ObjectSnapshot
This commit is contained in:
@@ -397,6 +397,21 @@ extension ObjectPublisher where O: CoreStoreObject {
|
||||
return FieldContainer<OBase>.Virtual<V>.read(field: object[keyPath: member], for: rawObject) as! V?
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the value for the property identified by a given key.
|
||||
*/
|
||||
public subscript<OBase, V>(dynamicMember member: KeyPath<O, FieldContainer<OBase>.Coded<V>>) -> V? {
|
||||
|
||||
guard
|
||||
let object = self.object,
|
||||
let rawObject = object.rawObject
|
||||
else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return FieldContainer<OBase>.Coded<V>.read(field: object[keyPath: member], for: rawObject) as! V?
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the value for the property identified by a given key.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user