Open
Description
http://www.synappse.pl/swift-first-steps-singleton/
//
// Singleton.swift
// Test
//
// Created by Sebastian Suchanowski on 6/5/14.
// Copyright (c) 2014 Synappse. All rights reserved.
//
import Foundation
class Singleton {
class func sharedInstance() -> Singleton! {
struct Static {
static var instance: Singleton? = nil
static var onceToken: dispatch_once_t = 0
}
dispatch_once(&Static.onceToken) {
Static.instance = self()
}
return Static.instance!
}
@required init() {
}
}