Search code examples
iosswiftinitializer

Cannot find an initializer for type


I'm getting an error saying

Cannot find an initializer for type 'SmileyScene' that accepts an argument list of type '(fileNamed: String)'

I'm new to swift please help.

import UIKit
import SpriteKit

introLabel?.runAction(fadeOut, completion: {
let doors = SKTransition.doorwayWithDuration(2.0)
let smileyScene = SmileyScene(fileNamed: "SmileyScene")
self.view?.presentScene(smileyScene, transition: doors)

Solution

  • The compiler is telling you that the type SmileyScene does not declare an initializer with the arguments you are trying to use to initialize your smileyScene constant.

    Make sure that your implementation of SmileyScene contains the appropriate initializer and that the initializer is visible to "the outside world." That is, the initializer should not be marked private.