1
如何使用Swift 3.0和Alamofire在iOS下载PDF文件。我可以使用nsurlsession获取网址。但我正在寻找alamofire的代码。 请看我的代码。如何从json在swift和alamofire下载pdf文件到ios中?
func downloadPdffile(_ sender : UIButton) {
print(sender.tag)
print("ARRAY VALUES FROM CELL",totalSyllabusArray.object(at: sender.tag))
var localDic :NSDictionary!
localDic = totalSyllabusArray.object(at: sender.tag) as! NSDictionary
let filepath = localDic["filepath"] as! String
print("pressed ")
let strURL1:String = FETCH_InMegh_Image_BaseURL + filepath
print("strURL1 is ",strURL1)
let pathURL = URL(string: strURL1)!
let sessionConfig = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfig)
let request = try! URLRequest(url: pathURL, method: .get)
let task = session.downloadTask(with: request) { (tempLocalUrl, response, error) in
if let tempLocalUrl = tempLocalUrl, error == nil {
// Success
if let statusCode = (response as? HTTPURLResponse)?.statusCode {
print("Success: \(statusCode)")
print("tempLocalUrl: \(tempLocalUrl)")
} else {
print("Failure: %@", error?.localizedDescription);
}
}
}
}
}
如何问一个问题。您可以为自己运行搜索。但是你正在寻求一个教程,图书馆,这不是一个可以接受的问题。 –
我没有让你@ElTomato – Ram