I had a Swift file that worked fine in Xcode6. When I upgraded to Xcode7, I now get an error that prevents the program from compiling. Below is the code snippet that is not working. The error that I receive just states "Could not find overload for 'PathForResource' that accepts the supplied arguments."
func playRecord(sender:UITapGestureRecognizer){
var tag = sender.view!.tag
let sound:NSURL
switch tag{
case 0: // red
sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("red", ofType: "wav")!)!
case 1: // blue
sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("blue", ofType: "wav")!)!
case 2: // white
sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("white", ofType: "wav")!)!
default:
sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("red", ofType: "wav")!)!
}
do {
audioPlayer = try AVAudioPlayer(contentsOfURL: sound)
} catch _ {
audioPlayer = nil
}
audioPlayer.prepareToPlay()
audioPlayer.play()
}