Skip navigation.
 
mlSuppressing the "Couldn't save document" sheet
FROM : Mark Alldritt
DATE : Wed Apr 13 19:40:47 2005

Hello All,

What is the correct way to prevent the "Couldn't save document" sheet from
appearing?  I have several cases where I cannot save a document and I want
to offer the user alternatives of my own.

For example, since my app creates applications, its possible for my user to
try and save over a running application.  I want to (a) warn the user they
are saving over a running app and (b) offer to quit the app and proceed with
the save.

Since I'm using sheets for all this and I detect problems like this in the
NSDocument writeToFile:... method, I must return NO after posting my alert
sheet.  At that point, Cocoa insists on showing the "Couldn't save document"
sheet once my sheet(s) have been dismissed.

I've found that I can suppress the "Couldn't save document" sheet by raising
an exception from writeToFile:.., but this seems like it might cause
problems as the exception is logged as uncaught.

I've received suggestions that I look at the TextEdit sample code for
solutions to my document saving problems, but TextEdit does not use
NSDocument so its not terribly helpful.

Cheers
-Mark

------------------------------------------------------------------------
Mark Alldritt                      Late Night Software Ltd.
Phone: 250-380-1725                Script Debugger 3.0 - AppleScript IDE
WEB:  http://www.latenightsw.com/  Affrus 1.0 - Perl Debugging

Related mailsAuthorDate
mlSuppressing the "Couldn't save document" sheet Mark Alldritt Apr 13, 19:40
mlRe: Suppressing the "Couldn't save document" sheet Jonathon Mah Apr 13, 19:47
mlRe: Suppressing the "Couldn't save document" sheet Mark Alldritt Apr 15, 20:21