Apple 关于创建临时 URL 的说明是使用FileManager.url(for:in:appropriateFor:create:)
. 他们给出的例子是(用 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
}
文档说appropriateFor
参数“确定返回 URL 的数量”,但我不明白这是什么意思。这个参数有什么用,我应该如何确定要为其传递的 URL?