How to play a simple system sound
audio, ios, objective-c
Solution
This is how I play the system tock sound. As simple as could be. Just find the name of the sound you are trying to play.
Don't forget to import `#import <AVFoundation/AVFoundation.h>` And add `AVFoundation.framework` in target's build phases.
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"]] error:NULL];
[audioPlayer play];
Problem
I just need to play a simple sound, I have app that send messages, and I need to play "message sent" system sound when message get sent.