title: Play Sound Using AVFoundation with Swift 2
body: <p>I am trying to play a sound in my iOS app (<strong>written in Swift 2</strong>) using AVFoundation. I had it working with no issues with the previous version of Swift. I am using Xcode 7.0. I am not sure what the issue is and cannot find any additional info for Swift 2 regarding playing sounds. Here's my code for the sound part:</p>
  
  <pre><code>import AVFoundation
  
  class ViewController: UIViewController {
      var mySound = AVAudioPlayer()
  
      override func viewDidLoad() {
              super.viewDidLoad()
          mySound = self.setupAudioPlayerWithFile("mySound", type:"wav")
  
          mySound.play()
      }
  
      func setupAudioPlayerWithFile(file:NSString, type:NSString) -&gt; AVAudioPlayer  {
              var path = NSBundle.mainBundle().pathForResource(file, ofType:type)
              var url = NSURL.fileURLWithPath(path!)
  
              var error: NSError?
  
              var audioPlayer:AVAudioPlayer?
              audioPlayer = AVAudioPlayer(contentsOfURL: url, error: &amp;error)
  
              return audioPlayer!
      }
  }
  </code></pre>
  
  <p>I am getting this error but have a feeling there maybe some other issue:</p>
  
  <blockquote>
    <p>'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?</p>
  </blockquote>