Daily iOS
Architecture

Singleton pattern

When do you use a singleton in an iOS app, and what's the problem with it?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A singleton guarantees one instance and gives a global access point. It fits process resources that really are one of a kind (a logger, settings), but hidden dependencies, global state, and no test isolation are the problems.

Share a question