Created
July 20, 2017 23:22
-
-
Save bhrott/9c51e0ca7ad2d65aa69199400e3f1140 to your computer and use it in GitHub Desktop.
Save temporary file swift 3
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
private func createTempFile(_ file: Data) throws -> URL { | |
let dir = NSTemporaryDirectory() | |
let fileName = NSUUID().uuidString | |
let url = NSURL.fileURL(withPathComponents: [dir, fileName])! | |
try file.write(to: url) | |
return url | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment