0Pricing
Swift Academy · Lesson

override, final and Preventing Subclassing

Overriding methods/properties and sealing classes with final.

Welcome

The `override` keyword lets subclasses replace superclass implementations. `final` prevents further overriding or subclassing, protecting your API contract.

override Methods

```swift class Animal { func speak() { print("...") } } class Cat: Animal { override func speak() { print("Meow") } } Cat().speak() // "Meow" ``` `override` is mandatory — the compiler rejects accidental shadowing.

All lessons in this course

  1. Class Inheritance and the super Keyword
  2. override, final and Preventing Subclassing
  3. Type Casting: is, as?, as! and as
  4. Deinitializers and Memory Lifecycle
← Back to Swift Academy