Implement a singleton class


I want to create a Singleton class.


// Creating our Singleton

class SharedManager {
    // Declare our 'sharedInstance' property
    static let sharedInstance = SomeManager()

    // Set an initializer - 
    // it will only be called once
    init() {
        print("SomeManager initialized")

    // Add a test function
    func doSth() {
        print("I'm doing something")

// The 'init' function will 
// only be called the first time


Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)