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 (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to