Re: saveDocument newbie question
Re: saveDocument newbie question
- Subject: Re: saveDocument newbie question
- From: Andrew Merenbach <email@hidden>
- Date: Sun, 18 Jun 2006 15:19:08 -0700
Hi, Neto! Unfortunately, I have some bad news for you: the docs say,
about -windowShouldClose:,
This method may not always be called. Specifically, this method is
not called when a user quits an application. Additional information
on application termination can be found in Graceful Application
Termination.
I'm not well-versed in the best ways of doing this, but I suggest
that you make your window the application delegate and use something
like (typed in Mail, and without knowing your app's architecture):
- (void)windowWillClose:(NSNotification *)notification {
[self saveDocument:self];
}
"Doing stuff" something from -xShouldY:, where X is window, or
anything else, and Y is an action, or anything else, can cause
problems. What if -saveDocument: throws an exception? Your whole
application could lock up on quit, going into a limbo state. Or
something weird.
I can't guarantee that my solution above will work--there may be
NSDocument-based methods that work better, anyway. But hopefully
it's an idea that will help you somewhat.
My greatest suggestion: Look at the NSDocument and NSWindow API
reference whenever you get the chance--it's very helpful.
Good luck, Neto!
Cheers,
Andrew
On Jun 18, 2006, at 2:29 PM, Neto wrote:
Hi all,
Sorry for the newbie question.
I'm trying to implement saveDocument when the user closes the
active window.
So I'm using:
- (BOOL)windowShouldClose:(id)sender
{
[self saveDocument:self];
return YES ;
}
It works fine with an already saved file, but it doesn't work with
a never saved file, because the window close before the user imput.
Any tips on what I'm doing wrong?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40ucla.edu
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden