Dispatch The free function dispatch_once is no longer available in Swift. In Swift, you can use lazily initialized globals or static properties and get the same thread-safety and called-once guarantees as dispatch_once provided. Example:
static let doOnce = { … global contains initialization in a call to a closure … }()
_ = doOnce // using myGlobal will invoke the initialization code only the first time it is used.