Search code examples
xcodeswiftdesignated-initializer

Check designated initializer in xcode


Is there any way to find out which initializer is the designated one in super class in Xcode?
I type super().init.. then, Xcode shows all initializers of superclass. I want to know is there any sign or symbol to point out which is the designated one?

Also a quick question. A designated initializer(DI) in subclass is allowed to only call a convenience initializer(CI) in superclass since the CI in superclass will eventually call the DI in superclass. Correct me if I'm wrong, thanks.


Solution

  • In Swift, any initializer not marked with the keyword "convenience" is a designated initializer.

    And designated initializers are required to call a designated initializer in their immediate superclass, per The Swift Programming Language. They cannot call a convenience initializer.