hamobi
hamobi

Reputation: 8130

SWIFT - KVO in xcode 6 beta 6.. observeValueForKeyPath no longer called

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

Answers (1)

hamobi
hamobi

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

Related Questions