Categories
ios nsuserdefaults swift

Detect changes on NSUserDefaults with suiteName

I created appGroups and did set up a NSUserDefaults using that group. I have a observer for which is not triggered when the value is changed.

let defaults = NSUserDefaults(suiteName: "group.daniesy.text")!            
defaults.addObserver(self, forKeyPath: "temp", options: NSKeyValueObservingOptions.New, context: nil)
defaults.setBool(!defaults.boolForKey("temp"), forKey: "temp")
defaults.synchronize()
override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer<Void>) {
println("changed")
}

However if i ignore the appGroup and use NSUserDefaults.standardUserDefaults() it works as expected.
Any idea why it’s not working?