what I've done is setup the com.apple.security.files.downloads.read-write
to true
, and have looked up the Apple Sandbox related docs, but I can't figure out how to get the downloads folder path, what I get is still container path like this: /Users/username/Library/Containers/com.errpro.Snell/Data/Downloads
, the method I use is NSSearchPathForDirectoriesInDomains
. I've seen someone use getpwent
to get the path, but seems not appropriate. Any help would be appreciated.
You should use the method URLForDirectory. This method find the name of the current user and insert it in the URL path.
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *downloadsURL;
downloadsURL = [fm URLForDirectory:NSDownloadsDirectory
inDomain:NSUserDomainMask appropriateForURL:nil
create:YES error:nil];