How to play a sound effect
This is a rather cryptic setup, but here’s how it works:
SystemSoundID soundID; NSString *soundFile = [[NSBundle mainBundle]pathForResource:@"yourfile" ofType:@"wav"]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID); AudioServicesPlaySystemSound(soundID);
This snippet assumes you’re using a file called yourfile.wav which needs to present in your project. You’ll also need to import the AudioToolbox Framework and import it in your header file.