Skip to content

Instantly share code, notes, and snippets.

@federicocappelli
Created February 21, 2018 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save federicocappelli/ba95be8a28c0aa6d9597a50fc1c12b07 to your computer and use it in GitHub Desktop.
Save federicocappelli/ba95be8a28c0aa6d9597a50fc1c12b07 to your computer and use it in GitHub Desktop.
iOS Error management snippet 2
func getDataFromUrl(url: URL, completion:(_ data: Data?, _ error: NSError?) -> Void) {
...
if (error) {
// Show error in UIAlertcontroller
//or
//send it up with a delegate/completion block to the higher level of the app.
}
else if (data) {
// Do something
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment