How to enable sound notification in OSX using Cocoa?

When the Finder finishes copying the files, it triggers a sound alert. How can I do this from my application?

Please note that this is not the same as just playing sound. I am from Windows, so I assume that OSX allows users to customize the sound of notifications from some central location. So, if the user selects a different sound for the event, then this API should play this new sound. Thus, I can make my gel for the application in the system, and he will be able to warn the user using a sound that the user knows.

+5
source share
3 answers

Answering my own question.

- , , , , , .

NSBeep - , . Lion.

  • /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds
  • Resources . /System/Library/CoreServices/.

, , , .

NSSound *systemSound = [[NSSound alloc] initWithContentsOfFile:@"/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/dock/drag to trash.aif" byReference:YES];
if (systemSound) {
    [systemSound play];
}

. SystemSounds Lion /System/Library/Components/CoreAudio.component/Contents/Resources/SystemSounds.

+5
NSSound(named: "Funk")?.play()
+1
source

All Articles