Twitter | Search | |
Cédric Luthi Feb 11
I’m still trying to use Swift but every time it ends up in tears. Today's failure is KVO. First issue, it’s ugly: player.addObserver(self, forKeyPath: (\AVPlayer.timeControlStatus)._kvcKeyPathString!, options: [.new, .old], context: &PlayerObserver.timeControlStatusContext)
Reply Retweet Like
Cédric Luthi Feb 11
Replying to @0xced
Well, really ugly (look, 3 ! on the same line): let oldStatus = AVPlayer.TimeControlStatus(rawValue: change![NSKeyValueChangeKey.oldKey] as! Int)! Then I learn about the much nicer observe(_:options:changeHandler:) on and I think it will be alright.
Reply Retweet Like
Michael Tsai
Oddly, the new observe() method doesn’t show up in Dash, either. I knew it was there, but couldn’t find it. And Xcode’s indexing was messed up, so it couldn’t show the synthesized header for it, either.
Reply Retweet Like More
Rob Mayoff Feb 12
Replying to @mjtsai @0xced
It's not documented because it's implemented by the _KeyValueCodingAndObserving protocol, and Apple doesn't document underscored APIs.
Reply Retweet Like
Rob Mayoff Feb 12
Replying to @mjtsai @0xced
You can find the declaration here: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/swift/Foundation.swiftmodule/arm64.swiftinterface
Reply Retweet Like