[swift-dev] KVO Context Param

Jordan Rose jordan_rose at apple.com
Thu Oct 6 16:24:18 CDT 2016


Hi, Tyler. Swift doesn't guarantee stable addresses for anything but top-level and static variables, so you'd have to declare a 'var' to make a valid KVO context anyway. It's not a great situation, but it's unlikely to change any time soon.

Jordan


> On Oct 6, 2016, at 14:07, Tyler Stromberg via swift-dev <swift-dev at swift.org> wrote:
> 
> Hey everyone,
> 
> One of the things that came up in a code review today was the type of KVO's context param. If you look at the function signature it gets imported as UnsafeMutableRawPointer?. Is there ever a need to mutate this parameter, and if not can we change it to be UnsafeRawPointer? instead?
> 
> We commonly define a constant (e.g. kvoContext = 0) to pass in, but in Swift we have to make it mutable (which we'd rather not do). Is there another workaround? How is everyone else handling this? (We avoid KVO whenever possible, but some APIs require it.)
> 
> Thanks,
> 
> -Tyler
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20161006/5d276186/attachment.html>


More information about the swift-dev mailing list