Crashed on Smart Key Path KVO when values are enums
wordlessj opened this issue · comments
Javier Zhang commented
Current implementations of producer(for:)
and signal(for:)
use old Objective-C API, which get values from value(forKey:)
. It works for most types except enums, value(forKey:)
returns an NSNumber
, then force-casted to the original enum type, which crashes. Maybe we should use Swift KVO API instead?
Javier Zhang commented
I may not have made It clear, this PR is the origin of the crash. It gets values from value(forKey:)
which returns NSNumber
for enums, then producer(for:)
and signal(for:)
force cast NSNumber
to the specific enum type which will crash. If we use the Swift KVO api, values passed to the closure will be the correct type.