The problem is that your completion blocks parameters are all implicitly unwrapped optionals whereas the latest Swift compiler expects them to be simply optionals (the latter makes more sense because you can reasonable expect them to be nil).So, the following code will compile in Xcode 7.0b5.let messageURL = NSURL(string: https://www.apple.com) let sharedSession = NSURLSession.sharedSession() let downloadTask: NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(messageURL!, completionHandler: { (location: NSURL?, response: NSURLResponse?, error: NSError?) -> Void in let urlContents = try! NSString(contentsOfURL: location!, encoding: NSUTF8StringEncoding) print(response : (response)) print(urlContents) }) downloadTask.resume()I had to make four changes:the above-mentioned change to the completion block parameters in line 5adopting Swift 2 error handling in line 7switching from var to let, also in line 7force unwrapping location, still in line 7Of course this code is still not correct because, if th
Topic:
App & System Services
SubTopic:
Networking
Tags: