• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: saveDocument newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: saveDocument newbie question
      • From: "Alan Smith" <email@hidden>
References: 
 >Excluding native file type from saveDocumentTo: accessory view. (From: Joshua Scott Emmons <email@hidden>)
 >saveDocument newbie question (From: Neto <email@hidden>)

  • Prev by Date: Application failing on copyWithZone:
  • Next by Date: Re: Application failing on copyWithZone:
  • Previous by thread: saveDocument newbie question
  • Next by thread: Re: saveDocument newbie question
  • Index(es):
    • Date
    • Thread