我已升级到Swift 2.0,当我尝试录音时遇到以下错误,但我并不太理解:
表达式的类型在没有更多上下文的情况下是模棱两可的
在 var recordSettings
上
我应该如何修复此错误,更重要的是为什么会出现这个错误?
var recordSettings = [
AVFormatIDKey: kAudioFormatAppleLossless,
AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,
AVEncoderBitRateKey : 320000,
AVNumberOfChannelsKey: 2,
AVSampleRateKey : 44100.0
]
var dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
var docsDir: AnyObject = dirPaths[0]
var soundFilePath = docsDir.stringByAppendingPathComponent("tempRecordzz")
var soundFileURL:NSURL = NSURL(fileURLWithPath: soundFilePath)
var error: NSError?
do {
recorder = try AVAudioRecorder(URL: soundFileURL, settings: recordSettings)
} catch var error1 as NSError {
error = error1
recorder = nil
}
kAudioFormatAppleLossless
在 Xcode7.0.1 中是UInt32
类型。 - rintaro