Swift Object ModelLesson 27Free preview
Swift Inheritance
This lesson is part of Swift · All levels
Summary
This lesson discusses inheritance in the Swift class. Subclasses inherit all the characteristics (properties and methods) of superclasses. Subclasses can override parent methods using the keyword 'override', call parent implementations with 'super', and prevent further subclassing using the keyword 'final'.
Key points
- The inheritance is expressed by the syntax ': Superclass' after the name Subclass
- The keyword 'override' must be written when hitting a method or property belonging to a superclass
- The keyword 'super' is used to access the original method or property belonging to the parent class
- The keyword 'final' prevents a class or method from being overridden by another class
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.