check for property via selector before using value(forKey:)

This commit is contained in:
Ilya Puchka
2018-09-11 18:12:27 +01:00
parent d71fe2a2ee
commit 0074ee1d4a
3 changed files with 12 additions and 2 deletions

View File

@@ -104,7 +104,9 @@ public struct Variable : Equatable, Resolvable {
#if os(Linux)
return nil
#else
current = object.value(forKey: bit)
if object.responds(to: Selector(bit)) {
current = object.value(forKey: bit)
}
#endif
} else if let value = current {
current = Mirror(reflecting: value).getValue(for: bit)