Reputation: 6500
How can I get the URL of /Users/Shared/
directory using SWIFT?
I can get URL of Application Support for the current user Like this
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
Upvotes: 0
Views: 402
Reputation: 285049
You can use
let sharedFolderURL = try! FileManager.default.url(for: .userDirectory,
in: .localDomainMask,
appropriateFor: nil,
create: false)
.appendingPathComponent("Shared", isDirectory: true)
Edit:
As no dynamic path component is involved you can even write
let sharedFolderURL = URL(fileURLWithPath: "/Users/Shared")
But /Users/Shared
is not a good solution to avoid a helper app to be able to write in /Library/Application Support
with elevated privileges.
Upvotes: 2