Reference types

The types you have seen so far in this book were mostly, if not all, reference types. Two types of objects are classified as reference types:

  • Classes
  • Closures

You have seen both of these object types in this book already. For instance, all UIViewController subclasses you have created are reference types. All closures that you used as callbacks or to perform animations in are also reference types.

So what does it mean if something is a reference type, and why should it matter to you? Well, reference types come with behavior that can be both convenient and very frustrating depending on what you are trying to achieve in your code.

One feature that is unique to reference types and classes is the ability to subclass. The only ...

Get Mastering iOS 12 Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.