Guest User

Untitled

a guest
Oct 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. func loadFilms() {
  2.  
  3. let id = filmId
  4. let apiKey = "97a0d64910120cbeae9df9cb675ad235"
  5. let url = URL(string: "https://api.themoviedb.org/3/movie/(id)?api_key=(apiKey)&language=en-US")
  6. let request = URLRequest(
  7. url: url! as URL,
  8. cachePolicy: URLRequest.CachePolicy.reloadIgnoringLocalCacheData,
  9. timeoutInterval: 10 )
  10.  
  11. let session = URLSession (
  12. configuration: URLSessionConfiguration.default,
  13. delegate: nil,
  14. delegateQueue: OperationQueue.main
  15. )
  16.  
  17. let task = session.dataTask(with: request, completionHandler: { (dataOrNil, response, error) in
  18. if let data = dataOrNil {
  19. do { let details = try! JSONDecoder().decode(Details.self, from: data)
  20.  
  21. }
  22. }
  23.  
  24. })
  25.  
  26. task.resume()
  27.  
  28. }
Add Comment
Please, Sign In to add comment