问题
When I set up to record audio, I get an error.
if (session.respondsToSelector("requestRecordPermission:")) {
AVAudioSession.sharedInstance().requestRecordPermission({(granted: Bool)-> Void in
if granted {
print("granted")
session.setCategory(AVAudioSessionCategoryPlayAndRecord, error: nil)
session.setActive(true, error: nil)
self.recorder ()
} else{
print("not granted")
}
})
}
Why do I get an error for having error: nil
?
回答1:
Like this:
try! session.setCategory(AVAudioSessionCategoryPlayAndRecord)
Let's see if you can figure out for yourself, from that model, how to fix the next line...
来源:https://stackoverflow.com/questions/32878965/swift-2-avaudiosession-setcategory-extra-argument-error