Chapter 5. Demystifying initializers

This chapter covers

  • Demystifying Swift’s initializer rules
  • Understanding quirks of struct initializers
  • Understanding complex initializer rules when subclassing
  • How to keep the number of initializers low when subclassing
  • When and how to work with required initializers

As a Swift developer, initializing your classes and structs are one of the core fundamentals that you have been using.

But initializers in Swift are not intuitive. Swift offers memberwise initializers, custom initializers, designated initializers, convenience initializers, required initializers, and I didn’t even mention the optional initializers, failable initializers, and throwing initializers. Frankly, it can get bewildering sometimes. ...

Get Swift in Depth now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.