tags:

views:

10

answers:

1

Hello,

i downloaded example from http://developer.apple.com/mac/library/samplecode/GLFullScreen/Listings/MyOpenGLView_h.html

in files MyOpenGLView.m and MainController.m is method - (void) dealloc

but when program terminated newer call this method.

I put there my code when program terminated but it isn't executed. How to make that method dealloc will called, or how to make other method that will call when program terminated?

Thanks in advance Chudziutki

+1  A: 

If you're looking specifically for a way to execute code right before the application is terminated, override your NSApplicationDelegate's applicationShouldTerminate: or applicationWillTerminate: methods.

jshier
I add to files MyOpenGLView.m and MainController.m- (void) applicationWillTerminate:(NSNotification *) notification{ NSLog (@"Terminate");}but this also is not called. I must make something more to make it working?
Chudziutki
You need to declare one of your classes as agreeing to the `NSApplicationDelegate` protocol. Implement the `applicationWillTerminate:` method in that class' `@implementation` section.
jshier