Making the mirroring support optionals & if the value is nil, it does not add it in the dictionary or asData array on the save
This commit is contained in:
parent
7fbe972873
commit
6b468a6f22
|
@ -86,30 +86,19 @@ extension Array where Iterator.Element == Mirror {
|
|||
var allChild : [String:Any] = [:]
|
||||
for mirror in self {
|
||||
mirror.children.forEach({ (child) in
|
||||
if let label = child.label {
|
||||
// Make sure our child has a label & the string describing the value is not nil. (Making optionals supported)
|
||||
if let label = child.label, String(describing: child.value) != "nil" {
|
||||
allChild[label] = child.value
|
||||
}
|
||||
})
|
||||
}
|
||||
return allChild
|
||||
}
|
||||
// var allChildrenData : [(String,Any)] {
|
||||
// var allChild : [(String,Any)] = []
|
||||
// for mirror in self {
|
||||
// mirror.children.forEach({ (child) in
|
||||
// if child.label.isNotNil {
|
||||
// allChild.append((child.label!, child.value))
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// return allChild
|
||||
// }
|
||||
}
|
||||
|
||||
extension Dictionary where Key == String, Value == Any {
|
||||
public func asData() -> [(String, Any)] {
|
||||
var data : [(String,Any)] = []
|
||||
// Remove out the superclass count which is private:
|
||||
for row in self {
|
||||
data.append(row)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ public protocol CCXMirroring {
|
|||
}
|
||||
|
||||
open class CCXMirror: CCXMirroring {
|
||||
private var superclassCount = 0
|
||||
// The superclass count will include CCXMirror, StORM, & Postgres-StORM by the time we get to the subclasses we need to process.
|
||||
private var superclassCount = 3
|
||||
public func didInitializeSuperclass() {
|
||||
self.superclassCount += 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue