Skip to content

Instantly share code, notes, and snippets.

@jzucker2
Created March 9, 2017 22:07
Show Gist options
  • Save jzucker2/48f5c434f34c3c4b689d0bad630c3e6c to your computer and use it in GitHub Desktop.
Save jzucker2/48f5c434f34c3c4b689d0bad630c3e6c to your computer and use it in GitHub Desktop.
guard let googleURL = URL(string: "https://www.google.com") else {
fatalError("What went wrong?")
}
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { (_) in
let task = URLSession.shared.dataTask(with: googleURL) { (data, response, error) in
if error != nil {
// handle error
print(error.debugDescription);
} else {
// we succeeded!
print(data.debugDescription);
print(response.debugDescription);
}
}
task.resume();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment