How do I make an HTTP request in Swift?

You can use URL, URLRequest and URLSession or NSURLConnection as you’d normally do in Objective-C. Note that for iOS 7.0 and later, URLSession is preferred. Using URLSession Initialize a URL object and a URLSessionDataTask from URLSession. Then run the task with resume(). let url = URL(string: “http://www.stackoverflow.com”)! let task = URLSession.shared.dataTask(with: url) {(data, response, error) … Read more