O'Reilly logo

Transitioning to Swift by Scott Gardner

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

Chapter    9

Subclassing and Extending

As stated in the introduction to the previous chapter, Swift is predominantly a protocol-based language. That said, the Swift standard library utilizes extensions expansively to build out the capabilities of its classes, structures, and enumerations. Following suit, this design pattern should also be adopted in custom code. When it comes to expanding the capabilities of a class, however, a choice must be made whether to subclass or extend. Subclassing provides certain capabilities not possible with extensions. In this chapter, the capabilities afforded by subclassing and extending will be explored in Swift, compared to each other and their counterparts in Objective-C.

Subclassing

Subclassing is a core tenet ...

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