在SWIFT中使用调度单例模型
class var sharedInstance:TPScopeManager { get { struct Static { static var instance : TPScopeManager? = nil } if !Static.instance { Static.instance = TPScopeManager() } return Static.instance! }}
class var sharedInstance:TPScopeManager { get { struct Static { static var instance : TPScopeManager? = nil static var token : dispatch_once_t = 0 } dispatch_once(Static.token) { Static.instance = TPScopeManager() } return Static.instance! }}
dispatch_once
无法将表达式的类型“void”转换为“()”类型
dispatch_once(Static.token, { Static.instance = TPScopeManager() })
dispatch_once
()
dispatch_once_t
梵蒂冈之花
白衣非少年