add Field.Coded dynamic lookups for ObjectPublisher and ObjectSnapshot

This commit is contained in:
John Estropia
2020-02-17 18:30:18 +09:00
parent 38e9878c04
commit 2d1b1e0592
3 changed files with 46 additions and 1 deletions

View File

@@ -209,6 +209,23 @@ extension ObjectSnapshot where O: CoreStoreObject {
}
}
/**
Returns the value for the property identified by a given key.
*/
public subscript<OBase, V>(dynamicMember member: KeyPath<O, FieldContainer<OBase>.Coded<V>>) -> V {
get {
let key = String(keyPath: member)
return self.values[key] as! V
}
set {
let key = String(keyPath: member)
self.values[key] = newValue
}
}
/**
Returns the value for the property identified by a given key.
*/