Comments
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
|
||||
|
||||
func unwrapOptional(_ object: Any) -> Any? {
|
||||
let mirror = Mirror(reflecting: object)
|
||||
guard mirror.displayStyle == .optional else { return object }
|
||||
guard let first = mirror.children.first else { return nil }
|
||||
return first.value
|
||||
}
|
||||
|
||||
extension Mirror {
|
||||
/// Return value from Mirror given name
|
||||
func getValue(forKey key: String) -> Any? {
|
||||
guard let matched = children.filter({ $0.label == key }).first else {
|
||||
return nil
|
||||
@@ -15,3 +9,12 @@ extension Mirror {
|
||||
return unwrapOptional(matched.value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return object and if it is an Optional return object Optional holds
|
||||
private func unwrapOptional(_ object: Any) -> Any? {
|
||||
let mirror = Mirror(reflecting: object)
|
||||
guard mirror.displayStyle == .optional else { return object }
|
||||
guard let first = mirror.children.first else { return nil }
|
||||
return first.value
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user