Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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
Swift ';Int';不可转换为';范围<;Int>';_Swift_Type Conversion_Xcode6 - Fatal编程技术网

Swift ';Int';不可转换为';范围<;Int>';

Swift ';Int';不可转换为';范围<;Int>';,swift,type-conversion,xcode6,Swift,Type Conversion,Xcode6,我最近从Xcode 6.0迁移到了Xcode 6.1,在一些以前编译得很好的代码上出现了编译错误 以下是导致错误的行: self.possibleWidgetUnits[widgetSizes.Small.rawValue] = WidgetFormat(width:1.0, height:1.0) 错误是: 'Int' is not convertible to 'Range<Int>' 这些线路有什么问题 编辑: enum widgetSizes : Int { case

我最近从Xcode 6.0迁移到了Xcode 6.1,在一些以前编译得很好的代码上出现了编译错误

以下是导致错误的行:

 self.possibleWidgetUnits[widgetSizes.Small.rawValue] = WidgetFormat(width:1.0, height:1.0)
错误是:

 'Int' is not convertible to 'Range<Int>'
这些线路有什么问题

编辑:

enum widgetSizes : Int {
case Small = 0
case Medium = 1
case Large = 2
}

分配WidgetFormat时可能会出现问题,您应该尝试删除“.0”xcode可能尝试声明Double而不是Int

像这样:

self.possibleWidgetUnits[widgetSizes.Small.rawValue] = WidgetFormat(width:1, height:1)

Xcode对于行的错误并不总是正确的,并且没有指出问题的正确来源。

你能发布
widgetSizes
的代码吗?@busina的答案似乎解决了问题这是Swift编译器产生的众多误导性错误消息之一。天知道有很多!
self.possibleWidgetUnits[widgetSizes.Small.rawValue] = WidgetFormat(width:1, height:1)