Does anyone know what the difference is between these two types?
The docs only refer to Int
but Xcode 6 auto complete only gives me Integer
when I type. I started using Integer
when porting code only to find that you have to cast between the two types.
For instance the following code gives the error Could not find an overload for '+' that accepts the supplied arguments.
var number1 : Int = 5
var number2 : Integer = 10
number1 + number2
Best Answer
An
Int
is the type whilst anInteger
is a protocol it implements.You should be using
Int
in declarations, i.e:which is also the type that's inferred for integer literals when a type isn't specified, i.e: