Skip to content

Instantly share code, notes, and snippets.

@bhrott
Created July 20, 2017 23:22
Show Gist options
  • Save bhrott/9c51e0ca7ad2d65aa69199400e3f1140 to your computer and use it in GitHub Desktop.
Save bhrott/9c51e0ca7ad2d65aa69199400e3f1140 to your computer and use it in GitHub Desktop.
Save temporary file swift 3
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