Subclassing SCNScene in Swift - override init

雨燕双飞 提交于 2019-12-11 07:46:50

问题


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?


回答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)
}
}


来源:https://stackoverflow.com/questions/26287108/subclassing-scnscene-in-swift-override-init

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!