Created
May 12, 2017 14:57
-
-
Save s4cha/6852ed28e66337ceda04ef7f0cdbb567 to your computer and use it in GitHub Desktop.
AsyncExample.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Say you're on the main thread | |
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async { | |
// Do something expensinve in background | |
var mySuperLongComputedResult = computeSuperLongStuff() | |
DispatchQueue.main.async { | |
// come back to the main thread to ping UI | |
label.text = mySuperLongComputedResult | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment