Create a convenience Initializer in a subclass that calls the failable Initializer

Tried a lot of output options below, but no one works.

import Foundation
import SceneKit


class test:SCNScene{
    override init(){
        super.init()
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }


    convenience init? (i:UIViewController){
        self.init(named:"") //Compile Error:use of self delegating initializer before self.init is called
    }

}

According to the Swift documentation , initialization rule 2 should not be initialized (named: String), is it possible that the initializer is available after implementation 2 has an initializer assigned? What am I wrong?

+4
source share
1 answer

Initialization Delegation Rule # 2 Specifies

The convenience initializer must call another initializer from the same class.

init? (named: String), ( № 2, ), .

self.init .

convenience init? (i:UIViewController){
        self.init()
        self.init(named:"") 
}
+8

All Articles