NSUserDefaults (this is the object that I'm observing) has exactly 2 observers: my ViewController (I add an observer programmatically) and xib's NSUserDefaultsController (which I tie up to a slider and an edit field in interface builder). Nevertheless, the ViewController's observeValueForKeyPath is called twice for some reason
2017-08-18 14:47 GMT+03:00 Alex Zavatone <z...@mac.com>: > Check to see how many observers you have. > > > On Aug 18, 2017, at 4:23 AM, Nick <eveningn...@gmail.com> wrote: > > > > Hello > > I am having a weird problem. > > I have a slider and a textfield with number formatter, both bound to a > > NSUserDefaultsController's "values" controller key and the "someVal" > > property. > > > > I am also registering for notifications in the -viewDidLoad of the view > > controller: > > > > [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath: > > @"someVal" options:0 context:nil]; > > > > > > The problem is that observeValueForKeyPath is being called twice every > time > > I move the slider or enter a new value in the edit. > > > > > > The viewDidLoad is executed only once (checked with an NSLog). > > > > > > It is easily reproducible. > > > > Why this might happen? > > > > macOS Sierra. > > _______________________________________________ > > > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > > > Please do not post admin requests or moderator comments to the list. > > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > > > Help/Unsubscribe/Update your Subscription: > > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com > > > > This email sent to z...@mac.com > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com