ler*_*bot 42 avfoundation ios xcode7 swift2
以下用于在Swift 1.2中工作:
var recordSettings = [
AVFormatIDKey: kAudioFormatMPEG4AAC,
AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,
AVEncoderBitRateKey : 320000,
AVNumberOfChannelsKey: 2,
AVSampleRateKey : 44100.0]
Run Code Online (Sandbox Code Playgroud)
现在,它给出了错误:
"没有更多的上下文,类型表达式是模糊的".
Unh*_*lig 57
您可以为编译器提供更多信息:
let recordSettings : [String : Any] =
[
AVFormatIDKey: kAudioFormatMPEG4AAC,
AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,
AVEncoderBitRateKey : 320000,
AVNumberOfChannelsKey: 2,
AVSampleRateKey : 44100.0
]
Run Code Online (Sandbox Code Playgroud)
Ste*_*han 35
符合参数要求的[String : AnyObject]格式recordSettings; 除了@ Unheilig的答案,你需要你的转换ints和floats到NSNumber:
let recordSettings : [String : AnyObject] =
[
AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatMPEG4AAC),
AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue as NSNumber,
AVEncoderBitRateKey : 320000 as NSNumber,
AVNumberOfChannelsKey: 2 as NSNumber,
AVSampleRateKey : 44100.0 as NSNumber
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50419 次 |
| 最近记录: |