Singleton design pattern

We will now look at the Singleton pattern. This design pattern defines the structure of a class that can have only one instance. A Singleton encapsulates a unique resource and makes it readily available throughout the application. The resource might be hardware, a network service, a persistent store, or anything else that can be modeled as a unique object or service. One example from Cocoa touch is a physical device running an iOS application; for an executing app, there is only one iPhone or iPad with a single battery and a screen. UIDevice is a Singleton class here, since it provides one channel to interact with the underlying features. In case the unique resource has a writable configuration this sort of discrepancy, ...

Get Reactive Programming with Swift 4 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.