Skip to content

Instantly share code, notes, and snippets.

@sbeitzel
Created November 9, 2020 00:11
Show Gist options
  • Save sbeitzel/ce44ae23beb3da2c9f94b7cbeb0af525 to your computer and use it in GitHub Desktop.
Save sbeitzel/ce44ae23beb3da2c9f94b7cbeb0af525 to your computer and use it in GitHub Desktop.
Creating a temporary file in Swift on MacOS
extension FileManager {
func tempFileURL(prefix: String = "", suffix: String = "") -> URL {
let uniqueString = UUID().uuidString
let fullFileName = "\(prefix)\(uniqueString)\(suffix)"
return temporaryDirectory.appendingPathComponent(fullFileName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment