1、添加头文件
#import <AudioToolbox/AudioToolbox.h>
2、添加框架
将AudioToolbox.Framework添加到Frameworks中
3、代码如下
NSString *path = [[NSBundle mainBundle] pathForResource:@"crunch"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);