![](https://blog.eternalstorms.at/wp-content/uploads/2022/02/Screenshot-of-System-Preferences-copy.jpg)
In System Preferences > Sound > Sound Effects, users have the choice to turn off user interface sound effects (as an example, that might be a “tick” sound when adjusting a slider, or a “lock/unlock” sound when clicking a Lock button).
But how do you respect that setting? NSSound surely doesn’t.
Well, I found two ways to do it:
The “Easy” Way
![](https://blog.eternalstorms.at/wp-content/uploads/2022/02/Screenshot-of-Xcode-18-02-22-14-49-19.png)
macOS has a key in the standard UserDefaults object
com.apple.sound.uiaudio.enabled
If it is present and set to true, it’s safe to play the ui sound.
The “Safe” Way
![](https://blog.eternalstorms.at/wp-content/uploads/2022/02/Screenshot-of-Xcode-18-02-22-14-52-13.png)
What if the UserDefaults key isn’t present? Or you just want to be absolutely certain that your sound respects the user’s setting?
Use the AudioToolbox APIs. It offers
AudioServicesSetProperty(kAudioServicesPropertyIsUISound,...)
which marks sounds as UI sounds, thus not playing if the user wishes them not to.
It’s a bit more work, but might be the safer way to do it.