Michael Long
Aug 1, 2024

--

That's a design decision and an implementation detail. Singletons can be easily programmed to timeout and free resources when needed, or on application phase change.

Further, if a given instance isn't referenced during a particular application launch and execution cycle it's not instantiated.

But the fact remains that the pattern exists to safeguard access to resources where one and only one reference to that resource should exist.

Might mention again that the article title promises to tell us why "singletons" aren't safe, and then goes on to illustrate examples of statics and global shared state... which aren't singletons.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet