Reputation: 8130
I have been debugging my app from beta 3 to beta 6
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?
Upvotes: 3
Views: 880
Reputation: 8130
a property has to have the word "dynamic" in front of it to be observable now..
dynamic var relativePosition: CGPoint = CGPointZero
Upvotes: 11