使用Xcode版本8.2.1(8C1002),为什么我在这里得到let result = "4247577657"
?我试图弄清楚我的代码是如何从我的url变量中提取的。
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let configuration = URLSessionConfiguration.default
configuration.allowsCellularAccess = true
let session = URLSession(configuration: configuration)
let url = NSURL(string: "http://kvisionphoto.com/4247577657.txt")
let task = session.dataTask(with: url as! URL) {
(data, response, error) in
guard let data = data else {print (error ?? "error") ; return}
let result = try? String(contentsOf: url as! URL)
print(result ?? "nil" )
PlaygroundPage.current.finishExecution()
}
task.resume()