I get an error

Playground execution failed: MyPlaygroundDeleteLast6.playground: 98: 28: (_st: String) {... ^

Here is the code:

class myClass { required convenience init(_ string:String) { self.init() print(string) } } class mySubclass: myClass { } 

Why? Shouldn’t convenience init just be inherited?

    1 answer 1

    Shouldn’t convenience init just be inherited?

    Should. But since you specified the required , it is necessary to override all designated initializers:

     class MyClass { required convenience init(_ string:String) { self.init() print(string) } } class MySubclass: MyClass { override init() { super.init() } } 

    either remove required

    • And why? What does it follow from? - tmm
    • @tmm from practical test. And why a minor initializer do you want required? - VAndrJ