Apple's instructions for creating a temporary URL are to use FileManager.url(for:in:appropriateFor:create:)
.
The example they give is (rewritten in Swift 3):
let desktopURL = URL(fileURLWithPath: "/Users/Noah/Desktop/")
do {
let temporaryDirectoryURL = try FileManager.default.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: desktopURL, create: true)
} catch {
// handle error
}
The docs say that the appropriateFor
parameter "determines the volume of the returned URL", but I don't understand what that means. What is this parameter for and how should I determine the URL to pass in for it?
The URL that you pass in is used to determine on which Volume (on which mounted disk) the temporary directory will be created. I suspect you should pass a URL to a file or folder that would reside on the same volume.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With