Singleton/SharedInstance Template for iOS 5 (ARC and GCD)
The singleton pattern is widely used in iOS to have a global, static class.
The most famous is [NSUserDefaults standardUserDefaults]
.
Over the years, the template for creating a singleton/SharedInstance has also changed. This is due to the introduction of new technologies in Apple’s SDK, particularly ARC and GDC.
The implementation has simplified to:
1 2 3 4 5 6 7 8 9 |
|
Nice piece of code added to my Xcode snippet.