Reputation: 103
I'm going over a programming example in a book on Swift and have an initializer to an SKScene that looks like this:
class GameOverScene: SKScene
{
init(size:CGSize,won:Bool,time:CFTimeInterval)
{
...........
}
}
This initializer is then called in another part of the program with the following line:
let gameOverScene=GameOverScene(size:self.size,won:true,time:CFTimeInterval)
It seems that this should all be fairly simple but then I get this strange looking error that says:
Cannot convert value of type 'CFTimeInterval.Type (aka 'Double.Type') to expected argument type 'CFTimeInterval' (aka 'Double').
Does anyone know (1) what this error means and (2) how to correct it?
Upvotes: 0
Views: 414
Reputation: 63271
CFTimeInterval
is a type. It's not an instance of CFTimeInterval
that you can pass into that function.
CFTimeInterval
is a typealias
to Double
. So this function expects a value of type Double
. 1.0
, NaN
, -1.5
, Double.pi
are all valid instances of Double
. But what you're trying to give it is CFTimeInterval
, which refers to the type itself.
This, for example, would work:
let gameOverScene = GameOverScene(size: self.size, won: true, time: 1.23)
Upvotes: 2