How to play system button click sound on iPad?

ios, ipad, objective-c, xcode

Solution

If you want to play a short sound (shorter than 30 sec), you can do it easily like this:

Note: You'll have to add AudioToolbox framework and import it (`#import <AudioToolbox/AudioToolbox.h>`)

SystemSoundID mySSID;

NSString *path = [[NSBundle mainBundle] pathForResource:@"beep" ofType:@"wav"];
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: path], &mySSID); 

AudioServicesPlaySystemSound(mySSID);

Also note that the file can be:

- No longer than 30 seconds in duration

- In linear PCM or IMA4 (IMA/ADPCM) format

- Packaged in a .caf, .aif, or .wav file

Problem

I need to play some system sound when users click button in my application which is running on iPad. How to implement it in iOS?

Original source