0

I'm having and error come up now that claims constant 'error' used before being initialized. I thought that is what I was doing by saying let e = error.

   let error: NSError?

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

hmm. Unsure what that is all about.

-sorry about that guys. here is the extra code....

//declare a variable to store the returned error if we have a problem instantiating our 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
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571

0 Answers0