• 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: How to quit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to quit


  • Subject: Re: How to quit
  • From: Wade Tregaskis <email@hidden>
  • Date: Tue, 8 Jun 2004 23:55:59 +1000

As part of learning Coca from instead of always using carbon. I have
managed to put something other which seems to work quite well in the time,
but now have a problem as is how to say I want to finish and quit this
application.

You might want to check out the terminate: method on NSApplication.

(Note: Be aware that this is quite different from the stop: method on NSApplication, because the stop method just calls CFRunLoopStop() (or whatever it is), which only exits from the current runloop, which may not be the root one and thus may not result in control returning to main(). Also not that you cannot call CFRunLoopStop() on a run loop other than the one you are in; doing so results in Bad Things, which in my case seems to be the whole system freezing some time soon after!).

Any pointers ???, as I need to call this from a registered "C" callback
mechanism within my application, as I register this callback with my
javascript functions, so when they want to quit, I need to quit out of here,
fairly sharpness I immediate. I guess "exit() would work", but I think
telling the Coca framework I want to quit would be better so I could then,
so something after in my main() proc.

Well, it's generally wise in a Cocoa app to not do anything in main except run NSApplication. Having said that, when your app does terminate (via the Quit command or any other method which results in terminate: being called) control will return to main().

However, you may also want to look at the atexit() function; it allows you to install a C function callback that is called whenever the application exits, including when you call exit() explicitly (or any other such exit function).

Wade Tregaskis (aim: wadetregaskis)
-- Sed quis custodiet ipsos custodes?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >How to quit (From: Mark Thomas <email@hidden>)

  • Prev by Date: Re: Checksums and best way to get'em
  • Next by Date: Re: How to quit
  • Previous by thread: How to quit
  • Next by thread: Re: How to quit
  • Index(es):
    • Date
    • Thread