O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When to inherit

There are circumstances where we do not have any other choice but subclassing. Here are some of examples of where subclassing is required:

  • When it is required by the APIs: For instance, many Cocoa APIs require the use of classes and being controversial is not recommended. For instance, UIViewController has to be subclassed.
  • When we need to manage and communicate our value types between instances of other classes: For example, when we need to draw a custom view in a Cocoa class provided by another drawing class, we will need to communicate it between them. Using a value type in this case is not beneficial.
  • When we need to share an instance between multiple owners: Core data persistence is an example. It can be very useful ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required