このAlamofireの方法で外部pdfファイルをダウンロードします。ダウンロードしたファイル(キャッシュ)を次回アプリケーションに開く
問題は、次回ユーザーがアプリケーションを開いたときに問題が残っていることです。したがって、ユーザーはpdfを再度ダウンロードする必要はありません。
私はdownloadedFilePathは、このようなものである
let destination =
Alamofire.Request.suggestedDownloadDestination(directory: .CachesDirectory,
domain: .UserDomainMask);
Alamofire.download(.GET, urlString, destination: destination)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
}
.response { request, response, _, error in
print("Downloaded to \(destination(NSURL(string: "")!, response!))");
}
をダウンロードするには、次のメソッドを使用します。
file:///var/mobile/Containers/Data/Application/4957AD15-947A-47D6-A126-EA06A5BCB099/Library/Caches/RewardMe-Presentation-at-NVIDIA-Auditorium.pdf
次回のアプリケーション起動時にファイルを保存するにはどうすればよいですか?
次回のアプリケーション起動時にそのパスをNSUserDefaultsに保存しましたが、ファイルは既に消えています。
NSDocumentDirectoryまたはNSBundleにファイルを保存してから、そこから入手してください –
どうすれば実現できますか? @AbdulRehmanWarraich – JayVDiyk