Woher in Swift 3 dispatch_once?

Okay, also habe ich von dem neuen @ erfahrSwifty Dispatch API in Xcode 8. Ich habe Spaß mitDispatchQueue.main.async, und ich habe mich im @ umgesehDispatch -Modul in Xcode, um alle neuen APIs zu finden.

Aber ich benutze auchdispatch_once um sicherzustellen, dass Dinge wie Singleton-Erstellung und einmaliges Setup nicht mehr als einmal ausgeführt werden (selbst in einer Multithread-Umgebung) ... unddispatch_once ist im neuen Versandmodul nirgends zu finden?

static var token: dispatch_once_t = 0
func whatDoYouHear() {
    print("All of this has happened before, and all of it will happen again.")
    dispatch_once(&token) {
        print("Except this part.")
    }
}

Antworten auf die Frage(14)

Ihre Antwort auf die Frage