Suggested approach: It’s very unlikely you’ll join a company where singletons are used extensively, so feel free to say that broadly speaking singletons aren’t great. Once you’ve given up that proviso, perhaps mention that Apple uses them extensively – thinks like UIApplication
, for example, are designed to exist only once. Finally, try to give a fresh example of your own, such as creating an app-wide logger.
For bonus points, perhaps compare and contrast SwiftUI’s environment.
Estimated difficulty: Advanced
Watch me answer this question in detail
See the full list of iOS interview questions
Link copied to your pasteboard.