In the Nav Services world one could specify kNavDontConfirmReplacement as an option to create a NavDialogRef that would not ask the user to confirm the replacement of a file when saving with a file name that already exists. How do I specify an equivalent behavior with the Cocoa NSSavePanel?
In the Nav Services world one could specify kNavDontConfirmReplacement as an option to create
Share
Here’s how it can be done:
- (NSString*)panel:(id)sender userEnteredFilename:(NSString*)filename confirmed:(BOOL)okFlagin your delegateokFlagisfalse, returnfilenamefilenameas anNSString*in your delegateNSSavePanelreturns to your code, pull the value of filename from your delegate method, and discard whatever filenameNSSavePaneltold you (which should be your unique string).Since
userEnteredFilename:is called by the OS before the confirm-replace check is made it gives you a chance to get what the user specified without letting the OS in on the secret. The unique string will assure that the confirm-replace dialog is not popped accidentally.Gross but efficacious.