Created
December 13, 2021 21:04
-
-
Save AhmedMenaim/335ec47ba790eacbbd58b2fc5252d881 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func savePdf() { | |
let pdfData = try? Data.init(contentsOf: URL(string: "http://www.africau.edu/images/default/sample.pdf")!) | |
let documentURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).first! as URL | |
let pdfNameFromUrl = "TestFile-\(Int.random(in: 1..<10000)).pdf" | |
let actualPath = documentURL.appendingPathComponent(pdfNameFromUrl) | |
do { | |
try pdfData?.write(to: actualPath, options: .atomic) | |
debugPrint(actualPath) | |
} | |
catch { | |
debugPrint(error.localizedDescription) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment