I’m new to Cocoa/macOS programming. I just found out that NSUserDefaults can be used to change application/system settings, like the way the defaults command does.
But I don’t know how to cause these settings to update.
e.g., I use NSUserDefaults to set the dock size to 32, and synchronize the setting. But the dock retains the old setting.
Even when I use defaults write com.apple.dock tilesize 32 to change its size, it won’t be updated until I logout and login.
Is there any other technology to notify the dock to get the update? I know that System Preferences can do that.
Thank you!
The Mac OS X dock doesn’t reload its settings until it is killed and restarted. In the same way that you’d have to change its settings manually via the terminal (
defaults write com.apple.dock tilesize 32; killall Dock), you have to do that in code. So, while you’ve written thedefaultsportion of the code, you have to write thekillportion:If you want to do this without killing the dock, sorry, but you’re out of luck. While there might be a hidden API to force the dock to reload its settings on the fly, in all my searching I have never found any hints of how one can do this (there are no notifications posted on the hidden distributed notification center that most applications to interact with one another).