Singleton with properties in Swift 3

For me this is the best way, make init private. Swift 3 \ 4 \ 5 syntax

// MARK: - Singleton

final class Singleton {

    // Can't init is singleton
    private init() { }

    // MARK: Shared Instance

    static let shared = Singleton()

    // MARK: Local Variable

    var emptyStringArray = [String]()

}

Leave a Comment