Inheritance and Method Overriding
Build class hierarchies in Objective-C with subclassing, override inherited methods, and call up to the superclass using super.
What is Inheritance?
Inheritance lets a class reuse and extend another class. The new subclass gets all the methods and properties of its superclass, then adds or changes behavior.
Declaring a Subclass
The colon syntax in the interface declares the superclass. Here Dog inherits from Animal.
@interface Dog : Animal
- (void)fetch;
@endAll lessons in this course
- Classes, Objects, and Methods
- Properties and Instance Variables
- Protocols and Categories
- Inheritance and Method Overriding