Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode swift 2字典含糊不清,没有更多的上下文_Xcode_Swift - Fatal编程技术网

Xcode swift 2字典含糊不清,没有更多的上下文

Xcode swift 2字典含糊不清,没有更多的上下文,xcode,swift,Xcode,Swift,在从1.2转换到swift 2时,我遇到了一个错误,表达式的类型是不明确的,没有更多的上下文 var recordSettings = [ AVFormatIDKey: kAudioFormatLinearPCM, AVSampleRateKey : 44100.0, AVNumberOfChannelsKey: 1, AVLinearPCMBitDepthKey : 32, AVLinearPCMI

在从1.2转换到swift 2时,我遇到了一个错误,表达式的类型是不明确的,没有更多的上下文

        var recordSettings = [
        AVFormatIDKey: kAudioFormatLinearPCM,
        AVSampleRateKey : 44100.0,
        AVNumberOfChannelsKey: 1,
        AVLinearPCMBitDepthKey : 32,
        AVLinearPCMIsFloatKey : true

我不知道是什么问题。我试着用[String:AnyObject]来施法,但没有成功。非常感谢您的建议。

类型推断器很难意识到
kaudioformlinearpcm
UInt32
的别名,并且可以在
NSNumber
中装箱

因此,帮助它:

var recordSettings:[String:AnyObject] = [
  AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatLinearPCM),
  AVSampleRateKey : 44100.0,
  AVNumberOfChannelsKey: 1,
  AVLinearPCMBitDepthKey : 32,
  AVLinearPCMIsFloatKey : true]