Loadex
Loadex

Reputation: 1512

'Int' is not convertible to 'Range<Int>'

I've recently migrated from Xcode 6.0 to Xcode 6.1 and i've got compilation errors on some code which previously compiled fine.

Here is the line causing an error :

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

The error is :

 'Int' is not convertible to 'Range<Int>'

Here is my variables declarations :

typealias WidgetFormat = (width:Int, height:Int)
var possibleWidgetUnits:[WidgetFormat]

What is wrong with these lines ?

EDIT :

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

Upvotes: 2

Views: 1284

Answers (1)

busina
busina

Reputation: 36

Your problem may come when you assign your WidgetFormat, you should try to remove the '.0' xcode may try to declare a Double and not an Int.

like this :

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

Xcode is not always right about the line's error and is not indicating the right origin of the problem.

Upvotes: 2

Related Questions