Swift - Part 26, Inheritance and overriding initializers

preview_player
Показать описание
Once you have understood the differences between a class and a structure in Swift, it is time to explore how initialization works. Whenever you subclass in Swift, you can initialize with default value are the instance variable definition to using the concept of initializers. Well depending up on how complex your class inheritance structure is, you may need to have parameterized initial
liners as well. In this video we have a look are how to define initializers in subclasses. We also have a look at how to override a function defined in super class. “final” keyword come in handy if you want to prevent a method being overridden in the subclass. You can use this with the declaration of the class as well. When used with a class definition, you basically prevent a class from being extended.

Рекомендации по теме
Комментарии
Автор

Thank you, I been going through documentation for 2 days trying to find how to correctly build chain of inheritance, and didn't find any "human" explanation. Russel Peters bless your channel!

illn
Автор

Thank you so much sir, this was an awesome explainer!

muskanmahajan
Автор

Thank you for this video! VERY HELPFUL!!!

amadoucamara
Автор

Thanks for the info...Subscribed to ur channel. But one suggestion/request that can u add details about "required init" in this video or separate video on it?

vyankatesha.shivnikar
Автор

when you're doing the initialization with super.init why does it become super.init(name: NAME) and not super.init(name: STRING)

devonquispe