代码帮助播放多个声音(目标c)到Swift(代码7)

代码帮助播放多个声音(目标c)到Swift(代码7),swift,function,xcode7,avaudioplayer,Swift,Function,Xcode7,Avaudioplayer,正在尝试将下面的代码objective-c转换为Swift,请帮助我这样做,或者使用新代码帮助我播放多个声音*** - (IBAction)pushButton { NSString *path = [[NSBundle mainBundle] pathForResouce:@"ring" ofType:@"mp3"]; if(theAudio) [theAudio release]; theAudio = [[AVAudioPlayer alloc]

正在尝试将下面的代码
objective-c
转换为
Swift
,请帮助我这样做,或者使用新代码帮助我播放多个声音***

- (IBAction)pushButton {    
      NSString *path = [[NSBundle mainBundle] pathForResouce:@"ring" ofType:@"mp3"];
      if(theAudio) [theAudio release];
      theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
      theAudio.delegate = self;
      [theAudio play];       
}

- (IBAction)pushButton1 {
      NSString *path = [[NSBundle mainBundle] pathForResouce:@"amaze" ofType:@"mp3"];
      if(theAudio) [theAudio release];
      theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
      theAudio.delegate = self;
      [theAudio play];
}
Swift版本:-

let path : String = NSBundle.mainBundle().pathForResource("ring", ofType: "mp3")!
if(theAudio){
    theAudio.release()
}
theAudio = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath:path), error: &err)
audioPlayer.delegate = self
audioPlayer.play()


func pushButton1(){
    let path : String = NSBundle.mainBundle().pathForResource("amaze", ofType: "mp3")!
    if(theAudio){
        theAudio.release()
    }
    theAudio = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath:path), error: &err)
    audioPlayer.delegate = self
    audioPlayer.play()

}

这不是编码服务。至少表现出你这边的努力!我从过去两周(每天5小时)就开始这样做,只是为了让它发挥作用。你能做什么?发帖!