• 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: Implementing Quit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Implementing Quit


  • Subject: RE: Implementing Quit
  • From: "Christopher Hickman" <email@hidden>
  • Date: Fri, 12 May 2006 15:06:51 -0400

According to the documentation for NSApplication, the delegate should return
not YES or NO from applicationShouldTerminate:, but one of the
NSApplicationTerminateReply constants:

NSTerminateNow: It is OK to proceed with termination.
NSTerminateCancel: The application should not be terminated.
NSTerminateLater: It may be OK to proceed with termination later. The
application must call replyToApplicationShouldTerminate: with YES or NO once
the answer is known. This return value is for delegates that need to provide
document modal alerts (sheets) in order to decide whether to quit.

So it looks like the correct answer here is if there is no need to save
changes, return NSTerminateNow and the app quits.  Otherwise it runs a "do
you want to save?" sheet and returns NSTerminateLater.  In the sheet
callback, you deal with the user's response to the sheet, and if they
responded "Don't Save" then you call replyToApplicationShouldTerminate:YES.

> -----Original Message-----
> From: cocoa-dev-bounces+tophu=email@hidden
> [mailto:cocoa-dev-bounces+tophu=email@hidden] On
> Behalf Of Paolo Bertani
> Sent: Friday, May 12, 2006 2:57 PM
> To: email@hidden
> Subject: Re: Implementing Quit
>
> But this invokes the delegate again...
>
> I have set up a flag to know if it is the second time the
> delegate is
> invoked
> (first time: user select quit,
> second time: the user don't want to save and the [NSApp
> terminate:self] is called)
>
> But is seem quite tricky while everything else in Cococa is
> much more
> straightforward.
> I feel I'm missing something about the single window application
> architecture...
>
> Anyway,
> 	thank you!
>
>
> > In the method that happens when you end the "do you want to save?"
> > sheet, call [NSApp terminate: self]
> >
> > Mike.
> >
> > On 12 May 2006, at 11:01AM, Paolo Bertani wrote:
> >
> >> I have implemented NSApplication delegate
> applicationShouldTerminate:
> >>
> >> If there is no need to save changes it returns YES and the
> app quits.
> >>
> >> Otherwise it runs a "do you want to save?" sheet and returns NO.
> >>
> >> If the user dismiss the sheet selecting "Don't save" or
> "Save" how
> >> do I quit instantaneously the application?
> >>
> >> BTW: The app. is single window and I don't have a document
> >> controller.
> >>
> >> Thank you.
> >>
> >> _______________________________________________
> >> Do not post admin requests to the list. They will be ignored.
> >> Cocoa-dev mailing list      (email@hidden)
> >> Help/Unsubscribe/Update your Subscription:
> >> 40gmail.com
> >>
> >> 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
>

 _______________________________________________
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

References: 
 >Re: Implementing Quit (From: Paolo Bertani <email@hidden>)

  • Prev by Date: Re: Implementing Quit
  • Next by Date: Re: Implementing Quit
  • Previous by thread: Re: Implementing Quit
  • Next by thread: Re: Implementing Quit
  • Index(es):
    • Date
    • Thread