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

Re: applicationShouldTerminate problem


  • Subject: Re: applicationShouldTerminate problem
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 4 Dec 2009 09:31:44 -0800


On Dec 3, 2009, at 12:25 AM, proger proger wrote:

int ret = NSRunAlertPanel(@"Save the work?", @"Do you want save the work?",

A modal alert is the wrong UI here. It should be a sheet on the window.

I used Interface Builder to delegate NSApplication with my delegate
controller. But don't see any results.

It sounds like you just tried closing the window, not quitting the app. Those are different things.


But i'm still have problem because
then NSAlert is shown(i don't see my application window, it hides)

The method name includes "AFTER last window closed". So after the user closes the window, the app terminates. The window's already gone by that point.


What you need to add is the NSWindow delegate method - windowShouldClose:. This runs when the user tries to close the window. You should move your save/discard/cancel logic to a separate method, and then call it from -windowShoudlClose, and also from - applicationShouldTerminate:. (Strictly speaking the latter should call it on every open window, but it sounds like your app only has one window.)

Note that since sheets are not modal, your -windowShouldClose should always return NO if it puts up the sheet. Then your completion handler for the sheet can close the window (unless the user canceled.)

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Fwd: applicationShouldTerminate problem (From: proger proger <email@hidden>)

  • Prev by Date: Saving position in NSTextView
  • Next by Date: Re: A hillegass challenge
  • Previous by thread: Re: applicationShouldTerminate problem
  • Next by thread: Why is "set" a class method of NSColor?
  • Index(es):
    • Date
    • Thread