var session = NSURLSession.sharedSession() session.dataTaskWithRequest(urlRequest, completionHandler: {(data: NSData!,
You can also use it simply by :-
let url = "api url" let nsURL = NSURL let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL) { (data, response, error) in // your condition on success and failure } task.resume()