I often recommend avoiding singletons in iOS apps, especially to pass data between view controllers.
I thought that most developers knew why the singleton pattern should be avoided and what is the correct approach.
So I was surprised when I discovered that many iOS developers don’t know this.
In this article, I’ll show you what a singleton is, why you should not use singletons in your apps and what you should use instead.
Matteo has been developing apps for iOS since 2008. He has been teaching iOS development best practices to hundreds of students since 2015 and he is the developer of Vulcan, a macOS app to generate SwiftUI code. Before that he was a freelance iOS developer for small and big clients, including TomTom, Squla, Siilo, and Layar. Matteo got a master’s degree in computer science and computational logic at the University of Turin. In his spare time he dances and teaches tango.