Basic Questions

What is in the handlers

on applicationWillFinishLaunching_(aNotification) aNotification?

on applicationShouldTerminate_(sender) sender?

Both are nowhere defined. But they work.

In a doc-based app they don’t.

Heiner

aNotification is NSApplicationWillFinishLaunchingNotification, and sender is a pointer to the application.

In a doc-based app they don't.

Are you sure?

Ok!

I tried this:

on awakeFromNib()
		
		set myNotificationCenter to current application's class "NSNotificationCenter"'s defaultCenter
		tell myNotificationCenter to addObserver_selector_name_object_(me, "applicationWillFinishLaunching:", "NSApplicationWillFinishLaunchingNotification", null)
		
		
	end awakeFromNib
	
	
	on applicationWillFinishLaunching_(aNotification)
		display alert "Hurra"
	end applicationWillFinishLaunching_

No ‘Hurra’, no error message

(To the pointer I’ll come later)

on applicationWillFinishLaunching_(aNotification)
on applicationShouldTerminate_(sender)

You get both of these for free, so you shouldn’t need to set them up with the notification center.

Many people are changing the default handler to read:

on applicationShouldTerminate_(sender)
  return true
end applicationShouldTerminate_

to avoid some quirks.

Thanks Dave,

but my problem is to implement this handlers into a doc-based app and there they do not work.

Did you make the file containing this code the app delegate? Only the app delegate gets sent these messages.

Craig,

Hurra!!! That’s it. It works.

Thank you so much. Maybe that solves all the other problems now.

Heiner

You’re welcome.

You might find this article informative.

Craig,

thank you for this note.
I think I’m not the only one who is interested on such supports.

Heiner