Skip to content

Instantly share code, notes, and snippets.

@fmo91
Created January 28, 2017 22:51
Show Gist options
  • Save fmo91/6c22d36f212f53ee07d20860526cc076 to your computer and use it in GitHub Desktop.
Save fmo91/6c22d36f212f53ee07d20860526cc076 to your computer and use it in GitHub Desktop.
// In the async side...
func someAsyncFunction(completion: @escaping (Error?) -> Void) {
// Something that takes some time to complete.
completion(nil) // Or completion(SomeError.veryBadError)
}
// In the consumer side...
someAsyncFunction { error in
if let error = error {
print("Oops! Something went wrong...")
} else {
print("It has finished")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment