Chapter 23. Singleton Pattern

Singletons are classes with a single instance. They are usually objects that provide an object-oriented interface to a single, often global, facility or resource. A class that manages a cache of database objects would want to create a single per-process instance of itself so that it could coordinate all of the object caching for the entire application. A class that provides file management methods could create a singleton object that all other classes would use to interact with the file system. The latter could also be implemented by defining a class that consists of nothing but class methods, but that pattern is unusual in Objective-C.

Singleton objects are typically created by an idempotent class method or C function ...

Get Learn Objective-C for Java Developers 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.