Re: Proper handling of NSSavePanel and 'Do you want to replace it?' dialog
Re: Proper handling of NSSavePanel and 'Do you want to replace it?' dialog
- Subject: Re: Proper handling of NSSavePanel and 'Do you want to replace it?' dialog
- From: Nick Zitzmann <email@hidden>
- Date: Fri, 16 Sep 2011 16:25:12 -0600
On Sep 16, 2011, at 12:33 PM, Sean McBride wrote:
> Hi all,
>
> NSSavePanel will automatically show the user a 'Do you want to replace' sheet if he tries to save with an existing name.
>
> What the correct way to proceed when replacement is needed?
>
> Option 1: First delete the existing item yourself. I've read this doesn't work when sandboxed (not sure if that's a bug or feature).
>
> Option 2: Append/overwrite the existing item. This works if you're writing a flat file and replacing a flat file. But if the existing item is a directory, writeToURL:::: is giving me an "Error Domain=NSPOSIXErrorDomain Code=21 "The operation couldn’t be completed. Is a directory")"
>
> What's the correct technique?
I performed a quick test using TextEdit as my guinea pig, and noticed that when TextEdit overwrites an existing RTFD bundle, TextEdit deletes the existing bundle and creates a new one in its place. (You can see this for yourself by using the fs_usage tool.) And since TextEdit is the most "Mac-like" app I know, I believe the correct technique is option 2 & deleting the existing directory if you get that error when trying to save.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden