According to the sandboxing docs, I recall that for sandboxing, there are a 
certain set of locations where you can save files to without requiring user 
permission.  Your ~/Documents folder is one of them. IIRC, all other locations 
require user confirmation to save the files.

Try saving to the docs folder and/or trying writing to the desktop with 
sandboxing disabled.

On Jan 27, 2016, at 8:42 PM, Graham Cox <[email protected]> wrote:

> I use -[NSData writeToURL:options:error] to write data to files in a location 
> generally chosen by the user. That works fine.
> 
> The default location is ~/Desktop, if the user fails to choose anything, or 
> if the bookmark of the previously chosen location fails to resolve. However, 
> when I try to write the file I get an error 513, ‘you don’t have permission’, 
> underlying error 1, operation not permitted’. If the user chooses the Desktop 
> themselves using the Open panel, it works fine.
> 
> The ~/Desktop permissions seem to be OK - I have readwrite permission on that 
> folder.
> 
> So something is weird about the URL for ~/Desktop when I create it 
> programatically as opposed to what NSOpenPanel returns. Note this isn’t a 
> sandboxed app, so that shouldn’t come into it.
> 
> I create the default URL thusly:
> 
>                       NSURL* desktopURL = [[NSFileManager defaultManager] 
> URLForDirectory:NSDesktopDirectory inDomain:NSUserDomainMask 
> appropriateForURL:nil create:YES error:&error];
> 
> 
> I can’t see any obvious difference between the URL here and the one I get 
> from NSOpenPanel, but there must be one.
> 
> 
> Any ideas what the problem could be here?
> 
> —Graham
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to [email protected]


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to