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, it can lead to problems such as race condition and deadlock. Since they are unique, Singletons act as a control, ensuring orderly access to the shared resource. Singletons may often be modeled as a server within the application that accepts requests to send, store, or retrieve data and configure the resource state.