SWIFT-xcode 6 beta 6中的KVO. [英] SWIFT - KVO in xcode 6 beta 6.. observeValueForKeyPath no longer called
本文介绍了SWIFT-xcode 6 beta 6中的KVO.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在将我的应用程序从Beta 3调试到Beta 6
I have been debugging my app from beta 3 to beta 6
我似乎无法调用observeValueForKeyPath..我在函数顶部放置了一个断点,但没有任何反应
I cannot seem to get observeValueForKeyPath to be called.. i put a breakpoint at the top of the function and nothing happens
self.gameScene.viewController.joystick.addObserver(self, forKeyPath: "relativePosition", options: .New, context: nil)
override func observeValueForKeyPath(keyPath: String!, ofObject object: AnyObject!, change: [NSObject : AnyObject]!, context: UnsafeMutablePointer<Void>) {
if keyPath == "relativePosition" {
// some code here
}
}
此代码之前运行正常..发生了什么变化?我什至无法在更基本的应用程序中使用它..还有其他需要做的事情吗?
this code was working without a hitch before.. has something changed? I can't even get this to work in a more basic app.. is there something else I need to do?
推荐答案
属性必须在其前面带有动态"一词,以便现在可以观察到.
a property has to have the word "dynamic" in front of it to be observable now..
dynamic var relativePosition: CGPoint = CGPointZero
这篇关于SWIFT-xcode 6 beta 6中的KVO.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文