Swift 2.0: Type of Expression is ambiguous without more context?

后端 未结 3 438
说谎
说谎 2020-12-30 20:32

The following used to work in Swift 1.2:

var recordSettings = [
    AVFormatIDKey: kAudioFormatMPEG4AAC,
    AVEncoderAudioQualityKey : AVAudioQuality.Max.ra         


        
3条回答
  •  梦毁少年i
    2020-12-30 21:11

    To comply to the required [String : AnyObject] format required by recordSettings parameter; In addition to @Unheilig's answer, you'll need to convert your ints and floats to 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
    ]
    

提交回复
热议问题