I've added an observer for an NSUserDefaults keyPath. This causes 
observeValueForKeyPath: to be called twice. Here's the call stack for the first 
call, starting from the setObject call (I'm actually calling setBool):

#0      0x0000000100007130 in -[AppDelegate 
observeValueForKeyPath:ofObject:change:context:] at 
/Users/tut/Projects/ButTunes/ButTunes/AppDelegate.m:505
#1      0x00007fffa196edbd in NSKeyValueNotifyObserver ()
#2      0x00007fffa196e654 in NSKeyValueDidChange ()
#3      0x00007fffa193d536 in -[NSObject(NSKeyValueObserverNotification) 
didChangeValueForKey:] ()
#4      0x00007fffa0011825 in __47-[CFPrefsSource 
didChangeValues:forKeys:count:]_block_invoke ()
#5      0x00007fffa001166a in forEachObserver ()
#6      0x00007fffa001178c in -[CFPrefsSource didChangeValues:forKeys:count:] ()
#7      0x00007fffa00113cf in -[CFPrefsSource 
setValues:forKeys:count:removeValuesForKeys:count:] ()
#8      0x00007fff9fef5550 in -[CFPrefsSource setValues:forKeys:count:] ()
#9      0x00007fff9ff3e71a in -[CFPrefsSource setValue:forKey:] ()
#10     0x00007fffa00606a2 in __108-[_CFXPreferences(SearchListAdditions) 
withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke
 ()
#11     0x00007fffa0060519 in -[_CFXPreferences(SearchListAdditions) 
withSearchListForIdentifier:container:cloudConfigurationURL:perform:] ()
#12     0x00007fffa008c955 in -[_CFXPreferences 
setValue:forKey:appIdentifier:container:configurationURL:] ()
#13     0x00007fff9ff3e664 in _CFPreferencesSetAppValueWithContainer ()
#14     0x00007fffa1964bbf in -[NSUserDefaults(NSUserDefaults) 
setObject:forKey:] ()

And the second callstack:

#0      0x0000000100007130 in -[AppDelegate 
observeValueForKeyPath:ofObject:change:context:] at 
/Users/tut/Projects/ButTunes/ButTunes/AppDelegate.m:505
#1      0x00007fffa196edbd in NSKeyValueNotifyObserver ()
#2      0x00007fffa196e654 in NSKeyValueDidChange ()
#3      0x00007fffa1aad2d7 in -[NSObject(NSKeyValueObservingPrivate) 
_changeValueForKeys:count:maybeOldValuesDict:usingBlock:] ()
#4      0x00007fffa1aacc2a in -[NSObject(NSKeyValueObservingPrivate) 
_notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] ()
#5      0x00007fffa001166a in forEachObserver ()
#6      0x00007fffa0011888 in -[CFPrefsSource 
_notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] ()
#7      0x00007fffa005fde2 in __84-[CFPrefsSearchListSource 
asynchronouslyNotifyOfChangesFromDictionary:toDictionary:]_block_invoke_2 ()
#8      0x00007fff9ff5130c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#9      0x00007fff9ff32634 in __CFRunLoopDoBlocks ()
#10     0x00007fff9ff31da5 in __CFRunLoopRun ()
#11     0x00007fff9ff317b4 in CFRunLoopRunSpecific ()
#12     0x00007fff9f4cdfbc in RunCurrentEventLoopInMode ()
#13     0x00007fff9f4cdcf9 in ReceiveNextEventCommon ()
#14     0x00007fff9f4cdc26 in _BlockUntilNextEventMatchingListInModeWithFilter 
()
#15     0x00007fff9dbb7b79 in _DPSNextEvent ()
#16     0x00007fff9e2cd1c3 in -[NSApplication(NSEvent) 
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#17     0x00007fff9dbac53d in -[NSApplication run] ()
#18     0x00007fff9db771ad in NSApplicationMain ()
#19     0x0000000100001af2 in main at 
/Users/tut/Projects/ButTunes/ButTunes/main.m:12

I requested both the old and new values in the change parameter. Both values 
are the same in each call stack. I'm running 10.12.1 in Xcode 8.1. This sure 
looks like a bug. Any way to fix it other than checking that the new value is 
really different than what's really in NSUserDefaults?

--
Steve Mills
Drummer, Mac geek


_______________________________________________

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

Reply via email to