Swift ';Int';不可转换为';范围<;Int>';
我最近从Xcode 6.0迁移到了Xcode 6.1,在一些以前编译得很好的代码上出现了编译错误 以下是导致错误的行: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
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)