You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up until Swift 4, "Using Swift with Cocoa and Objective-C" recommended "creat[ing] a global context variable" to take the address of to pass to the context parameter of `NSObject.addObserver(_:forKeyPath:options:context🙂`.
As of Beta 3, this practice fails runtime exclusivity checks, producing console logs and warnings in Xcode like:
Environment
Xcode version 9.0 beta 3 (9M174d) / swiftlang 900.0.52
Additional Detail from JIRA
md5: b013264626250a5532385bbccf726cb5
Issue Description:
Up until Swift 4, "Using Swift with Cocoa and Objective-C" recommended "creat[ing] a global context variable" to take the address of to pass to the context parameter of `NSObject.addObserver(_:forKeyPath:options:context🙂`.
As of Beta 3, this practice fails runtime exclusivity checks, producing console logs and warnings in Xcode like:
While the Swift 4 materials recommend use of the new `KeyPath`-based overlay, this leaves 3.2 users in a lurch.
Workarounds:
Replacing the context with an `unsafeBitCast` of a `Selector`
Replacing the context with an `unsafeBitCast` of a `Foo.self` metatype.
Removing the context (only applicable to 1-ary observations not involved in a class tree.)
The text was updated successfully, but these errors were encountered: