class func sharedInstance() -> ClassName { struct singleton{ static var once: dispatch_once_t = 0 static var instance: <span style="font-family: Arial,Helvetica,sans-serif;">ClassName</span><span style="font-family: Arial,sans-serif;">? = nil</span> } dispatch_once(&singleton.once,{ singleton.instance = <span style="font-family: Arial,sans-serif;">ClassName</span>() } ) return singleton.instance! }