I’ve attempted to add KVO to my NSUserDefaults
to watch for a value changing in Settings. I’ve added a breakpoint to my observeValueForKeyPath:object:change:context
method but it’s never called.
Here’s my code:
override init() {
super.init()
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: UserWantsUbiquityPreferenceKey, options: NSKeyValueObservingOptions.New, context: nil)
}
override func observeValueForKeyPath(keyPath: String!, ofObject object: AnyObject!, change: [NSObject : AnyObject]!, context: UnsafeMutablePointer<Void>) {
println("\(keyPath) changed to \(object)")
}