Search Your Question

When required init method is mandatory? What is that?

Ans :


Write the required modifier before the definition of a class initializer to indicate that every subclass of the class must implement that initializer.
You must also write the required modifier before every subclass implementation of a required initializer, to indicate that the initializer requirement applies to further subclasses in the chain. You do not write the override modifier when overriding a required designated initializer.
“The use of the required modifier ensures that you provide an explicit or inherited implementation of the initializer requirement on all subclasses of the conforming class, such that they also conform to the protocol.”

No comments:

Post a Comment