1.导入AVFoundation框架
import AVFoundation
2.获取音效对应的soundID
guard let url = NSBundle.mainBundle().URLForResource("123.wav", withExtension: nil) else{return}
let urlCF = url as CFURLRef
var soundID:SystemSoundID = 0;
AudioServicesCreateSystemSoundID(urlCF, &soundID)
3.根据soundID播放音效,带完成时回调
AudioServicesPlaySystemSoundWithCompletion(soundID) {
print("播放完成时回调")
//根据soundID释放音效
AudioServicesDisposeSystemSoundID(soundID)
}