let session = NSURLSession.sharedSession()
if let url = NSURL(string: someURL) {
let request = NSMutableURLRequest(URL: url)
let task = session.dataTaskWithRequest(request) { (data, response, error) in
if data != nil {
print(NSString(data: data, encoding: NSUTF8StringEncoding))
}
}
task?.resume()
}
This one works fine on Swift 1.2 ( with println and task.resume() ) and I was able to get the data as I expected.
But, when I run this code on Swift 2 (Xcode 7) I got rejected from the server. What is the correct way to implement this in Swift 2.0?