In mathematics and logic, a singleton is defined as “a set that contains exactly one element.” So no matter how big a pouch is, every time you are trying to get a marble out of it you will get only the same one. Under what situations do we need a singleton in software? Think about resources that can be shared only in a system and no copies of them can be made available to others. For example, the GPS device is the sole hardware on the iPhone that provides coordinates of the device in real time. The CLLocationManager class of the CoreLocation framework provides a single access point to any services that the GPS device offers. Some people may think, if I can make a copy of CLLocationManager, then can I get an extra set of GPS services to my application? That sounds like a fantasy—you create two copies of software GPS for the price of one hardware GPS. But in reality, you still get only one GPS at a single time because there is only one GPS in the device that makes actual connections with satellites in the sky. So if you think you wrote a killer app that can manipulate two separate GPS connections at a time and want to brag about it to your friends, think twice!


Access Point Design Pattern Factory Method Memory Management Object Creation 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Carlo Chung 2011

Authors and Affiliations

  • Carlo Chung

There are no affiliations available

Personalised recommendations