I\'m using Xcode 7 beta 2 and following raywenderlich.com\'s Breakout tutorial to learn SpriteKit. Here\'s the error I get when I try to load GameScene using unarchiveFromFile.<
You should use the init(fileNamed:)
initialiser, which is available from iOS 8 onwards. For example:
if let gameOverScene = GameOverScene(fileNamed: "GameOverScene") {
// ...
}
It's important to note that init(fileNamed:)
is a convenience initialiser on SKNode:
convenience init?(fileNamed filename: String)
Therefore, for GameOverScene
to automatically inherit init(fileNamed:)
, GameOverScene
must adhere to the following rules from The Swift Programming Language: Initialisation (rule 2 especially):
Assuming that you provide default values for any new properties you introduce in a subclass, the following two rules apply:
Rule 1 If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.
Rule 2 If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.