Xcode 8.0 beta3 AVAudioRecorder(url,setting) error catch - "Error Domain=NSOSStatusErrorDomain Code=-50 "(null)""
<p>I'm trying to record the voice of the user and change it to a text data. I used AVAudioRecorder to record the sound and SpeechKit to change it to text which is included in iOS 10. When user touches down the button record starts and stops when button is touched up. But when I initialize the AVAudioRecorder using do catch syntax, error occurs and fails.
I added the appropriate frameworks(Speech, AVFoundation).</p>

<pre><code>import UIKit
import Speech
import AVFoundation

class SearchViewController: UIViewController, CLLocationManagerDelegate, AVAudioRecorderDelegate {

    var audioRecorder = AVAudioRecorder()

    let recordSettings = [AVSampleRateKey : String(NSNumber(value: Float(44100.0))),
                      AVFormatIDKey : String(kAudioFileCAFType),
                      AVNumberOfChannelsKey : String(NSNumber(value: 2))]

@IBAction func recordButtonDown(_ sender: AnyObject) {

    print("recordButtonDown")

    self.audioPlayer.play()
    sleep(1)

    let fileManager = FileManager.default
    let paths = fileManager.urlsForDirectory(.documentDirectory, inDomains: .userDomainMask)
    var audioURL = paths[0] as NSURL
    audioURL = audioURL.appendingPathComponent("soundForMapSearch.caf", isDirectory: false)!

    do {
        self.audioRecorder = try AVAudioRecorder(url: soundFileURL as URL, settings: self.recordSettings)
        self.audioRecorder.delegate = self
        self.audioRecorder.prepareToRecord()
        self.audioRecorder.record()
    } catch (let error) {
        print("Error: \(error)")
    }
}

@IBAction func recordButtonUp(_ sender: AnyObject) {
    self.audioRecorder.stop()
}

override func viewDidLoad() {
    super.viewDidLoad()

    do {
    try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord)
    try audioSession.setActive(true)
    audioSession.requestRecordPermission({ (recordPermission) in
        })
    } catch {
        print("record initiallizing failed")
    }
</code></pre>

<p>And on the line </p>

<pre><code>self.audioRecorder = try AVAudioRecorder(url: soundFileURL as URL, settings: self.recordSettings)
</code></pre>

<p>error occurs at catch</p>

<pre><code>Error: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)"
</code></pre>

<p>is printed. I searched for this error and code=-50 means the NSURL object is invalid. How can I solve this error?</p>