Created
July 5, 2016 02:38
-
-
Save lfarah/91e1b1f9aa7bff3642a051d9031e3d5c to your computer and use it in GitHub Desktop.
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
| let urlPath: String = "http://api.giphy.com/v1/gifs/search?q=funny+cat&api_key=dc6zaTOxFJmzC&limit=1" | |
| let url: URL = URL(string: urlPath)! | |
| var request1: URLRequest = URLRequest(url: url) | |
| request1.httpMethod = "GET" | |
| request1.timeoutInterval = 60 | |
| let session = URLSession.shared() | |
| // do { | |
| /*try*/ | |
| let task = session.dataTask(with: request1) { (data, response, error) in | |
| do { | |
| print(error?.description) | |
| if let jsonResult = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as? [String: AnyObject] { | |
| print("ASynchronous\(jsonResult)") | |
| } | |
| } catch { | |
| print("error") | |
| } | |
| } | |
| task.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment