October 2017
Intermediate to advanced
210 pages
5h 32m
English
There are several ways to implement the singleton pattern in Swift. The way that is presented here uses class constants that was first introduced in version 1.2 of Swift. With this method, a single instance of the class is created the first time we access the class constant. We will then use the class constant to gain access to this instance throughout the lifetime of our application. We will also create a private initializer that will prevent external code from creating additional instances of the class.
Read now
Unlock full access