mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This change adds a new variant of "addObserver:forKeyPath:options:context:" that takes a "KVOContext" instead of an unsafe void*. The variant delegates to the original method, but first 'retain's the object before turning it into an unsafe pointer. The API is then matched with a variant of 'removeObserver:forKeyPath:context:' which delegates to the original method and then 'release's it. This vision here is that Swift clients of this API will use this variant, and not the unsafe one. A refinement (later) is to not expose the original methods at all, and provide a new method 'observeValueForKeyPath:ofObject:change:kvoContext:' that implements a thunk that delegates to 'observeValueForKeyPath:ofObject:change:context:' and does the void* cast (which the code in the test case does). This needs to go through API review; names are strawman names. Swift SVN r17325