So I need to register a function on OSX (using Xcode / objective C) that will register a particular function to be called whenever the program terminates.
I ran into this but i guess that's for iOS and not for OSX.
I replaced UI with NS and gave it a shot, but it did not work.
NSApplication *app = [NSApplication sharedApplication];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillTerminate:)
name:BeCalledOnExit object:app];
but that is not compiling. it says something on name: being an undeclared identifier when it is clearly on the .h & .m file before the function.
i ran into another chap who used this:
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender{
return TRUE
}
but it doesnt work for me as my app is a complete status bar app.
Basically i'm creating some temp files during my app and just before quitting, i want to make sure that my app is clearing out these files. I am putting it in /tmp/.. Woudn't want too much space to be taken.
i would really like to have a solution like in gcc/python,
atexit(functionName);