fun csessionDownloadImage(){
let url=URL(string: "http://hangge.com/blog/images/logo.png")
let request = URLRequest(url: url!)
let session = URLSession.shared
let downloadTask = session.downloadTask(with: request, completionHandler:
(location:URL?, response:URLResponse?,error:Error?)
-> Void in
print("location:\(String(describing: location))")
let locationPath = location?.path
let now = NSDate()
let timeInterval:TimeInterval = now.timeIntervalSince1970let timeStamp = String(timeInterval)
let documents:String =NSHomeDirectory()+"/Documents/ (timeStamp).png"
let fileManager = FileManager.default
try! fileManager.moveItem(atPath: locationPath!, toPath: documents)
print("new location:\(documents)")
})
downloadTask.resume()
}