Singleton dessing pattern in a template (Swift)

The aim of this post is just complement Singleton design pattern in a template post , but in Swift.

Singleton implementation class

 

Not that in Swift ‘dispatch_once’ is no longer necessary, as in Objective-C. Static constants in Swift, internally does it. So this is an issue that you do not have to worry about.

Template usage

This is how the pattern is used.

 

Conclusion

As you can see Swift language structure facilitates a lot Singleton design pattern implementation. You can get the project source code used for writing this post here.