ReactiveCocoa / ReactiveCocoa

Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crashed on Smart Key Path KVO when values are enums

wordlessj opened this issue · comments

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?

A good news is that is exactly #3491 which was merged recently.

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.

#3667 should had fixed this.