我现在有错误,并且在初始化之前声称持续'错误'。我认为这就是我所说的让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