我在初始化消息之前得到一个常量'错误'

时间:2017-04-22 23:11:22

标签: swift

我现在有错误,并且在初始化之前声称持续'错误'。我认为这就是我所说的让e =错误。

   let error: NSError?

   if let e = error {
        print(e.localizedDescription)
    } else {
        recorder.prepareToRecord()
        recorder.isMeteringEnabled = true
    }

HMM。不确定那是什么。

- 对那些家伙很好。这是额外的代码......

//如果我们在实例化AVAudioRecorder时出现问题,则声明一个变量来存储返回的错误

      let error: NSError?

    //Instantiate an AVAudioRecorder
    recorder = try? AVAudioRecorder(url: url, settings: recordSettings as! [String : AnyObject])

    //If there's an error, print otherwise, run prepareToRecord and meteringEnabled to turn on metering (must be run in that order)
    if let e = error {
       print(e.localizedDescription)
      } else {
        recorder.prepareToRecord()
        recorder.isMeteringEnabled = true

0 个答案:

没有答案