O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

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

CHAPTER 25

image

Singleton

Singleton Defined

Singleton is a design pattern where you can have only one instance of a class. Usually, when you define a class, you expect to use many instances of the class. But in some designs this doesn’t make sense.

For instance, an application may only need one reference to the file system (since there is only one file system). Or the app has a data model that should stay in sync and so you want to make sure you have only one instance of a class available.

To implement a Singleton pattern, you will need to create a special type of constructor and then only use this constructor to get a reference to the Singleton object. ...

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