+keyPathsForValuesAffecting<Key> in Swift 4 won't trigger a KVO callback in <Key> when the specified keypaths change

Originator:oscar
Number:rdar://32700827 Date Originated:11/06/2017
Status:Open Resolved:Duplicate of 32593787
Product:Swift Product Version:4
Classification:Bug Reproducible:Always
 
Steps to Reproduce:
Download the project "KVOObservationTestSwift" project attached and open it in Xcode 9, run it in the iOS simulator.

MyObject specifies "isReady" as a keyPath whose change affects `\MyObject.name`. Click the "Button" button on the simulator. That button tap flips the value of `isReady` on a `MyObject` instance. This should trigger a KVO callback on ViewController, but it doesn't.

Expected Results:
Changing values on keypaths specified by the class methods keyPathsForValuesAffecting<Key> on Swift 4 should actually trigger KVO notifications for <Key> when the returned keypaths are changed.

Observed Results:
Keypaths defined in keyPathsForValuesAffecting<Key> methods on Swift 4 do not trigger a change on <Key> when the returned keypaths are changed.

Version:
Xcode Version 9.0 beta (9M136h)
Swift 4

Notes:
If instead of using + keyPathsForValuesAffecting<Key> you return the keypaths from the keyPathsForValuesAffectingValue(forKey:) method, it works correctly.

Attached you can find test projects in Swift and Objective-C.

Comments

The function needs to be marked @objc

Yeah, they responded to me. There still seems to be an inconsistency with how it works. It's been marked as a duplicate of 32593787.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!