我如何在 swift2 中创建一个 [String : AnyObject] 数组

How can i create a [String : AnyObject] array in swift2

此代码片段适用于 swift,但无法使用 swift2.

编译
let settings = [
    AVFormatIDKey: kAudioFormatLinearPCM,
    AVSampleRateKey: 44100.0,
    AVNumberOfChannelsKey: 1,
    AVLinearPCMBitDepthKey: 16,
    AVLinearPCMIsBigEndianKey: true
]

let audioFile = AVAudioFile(forWriting:url, settings:settings, error:&error)

我收到 "Type of expression is ambiguous without more context" 错误。如果我将分配更改为 [String : Any] 我会在 AVAudioFile 处收到错误,因为它需要一个 [String : AnyObject] 数组。

let settings:[String : Any] = [
   AVFormatIDKey: kAudioFormatLinearPCM,
    AVSampleRateKey: 44100.0,
    AVNumberOfChannelsKey: 1,
    AVLinearPCMBitDepthKey: 16,
    AVLinearPCMIsBigEndianKey: true
]

let audioFile = try! AVAudioFile(forWriting:url, settings:settings)

有谁知道如何在 swift2 中创建 [String : AnyObject] 数组?

kAudioFormatLinearPCM 是一个 UInt32 但 Swift 2 想要一个 Int:

let settings: [String:AnyObject] = [
    AVFormatIDKey: Int(kAudioFormatLinearPCM),
    AVSampleRateKey: 44100.0,
    AVNumberOfChannelsKey: 1,
    AVLinearPCMBitDepthKey: 16,
    AVLinearPCMIsBigEndianKey: true
]