O'Reilly logo

Learning Swift by Andrew J Wagner

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

Creational patterns

The final type of design patterns that we will discuss are called creational patterns. These patterns relate to the initialization of new objects. At first, the initialization of an object probably seems simple and not a very important place to have design patterns. After all, we already have initializers. However, in certain circumstances, creational patterns can be extremely helpful.

A singleton/shared instance

The first patterns we will discuss are the singleton and shared instance patterns. We are discussing them together because they are extremely similar. First, we will discuss shared instance because it is the less strict form of the singleton pattern.

The idea of the shared instance pattern is that you provide an instance ...

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