1

I'm getting some compiler errors in Xcode 6 using Swift which I have a hard time wrapping my head around. I'm trying to create a scene by subclassing SCNScene, but keep getting errors on the initialisers. The basic structure of my code is:

class SpaceScene: SCNScene {
    override init(named: String) {
        super.init(named: named)
    }
}

This results in an error on line 2 with the message "Initializer does not override a designated initializer from its superclass", although SCNScene clearly has such an initialiser. I think i'm missing something basic - any insights?

air1982
  • 41
  • 2

1 Answers1

1

On XCode 6.1, the following should do it:

class SpaceScene : SCNScene {

override init() {
    super.init()
}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}
}
tod
  • 1,539
  • 4
  • 17
  • 43
uuxxaa
  • 21
  • 3
  • For the ones like me that were still looking for a away to provide init with named parameter on the subclass, there is no need after apply this solution. Convenience constructors are automatic made available once all designated constructors are available [link](https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/Initialization.html), role 2. – MiguelSlv Nov 10 '14 at 21:31