Created
November 9, 2020 00:11
-
-
Save sbeitzel/ce44ae23beb3da2c9f94b7cbeb0af525 to your computer and use it in GitHub Desktop.
Creating a temporary file in Swift on MacOS
This file contains hidden or 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
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