Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GokulKrish

macrumors newbie
Original poster
Apr 12, 2014
11
0
Chennai
Mac OS X- How to catch Logoff / Restart / Shutdown notifications and do few things before app/process terminates (Backgroud apps / Commandline tool ).

With foreground apps , I can achieve the same by using this delegate .
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender

But I do not want my application to run in foreground (i.e) shouldn't be shown on DOCK and App switcher . So I gave NSUIElement to 1 .
But during Logoff / shutdown , it does not allow to complete the -applicationShouldTerminate part . It kills the process midway .

Can any one please tell me how to achieve this using an app / commandline tool ?!!!

(In short, I need a Mac application that runs in background but gets applicationShouldTerminate's behaviour )

Thanks in advance .

PS : I already have tried NSApplicationActivationPolicy , it does same as NSUIElement 1 .


Regards ,
Gokul
 
Mac OS X- How to catch Logoff / Restart / Shutdown notifications and do few things before app/process terminates (Backgroud apps / Commandline tool ).

Maybe take a look at notifications. NSWorkspaceWillPowerOffNotification seems like a good place to start. There's some other stuff if you look at the documentation for NSWorkspace that might be useful. I've not used it myself, I'm afraid so I don't know whether you could pause shutdown for long enough for your app to do what it needs to do or not. Hopefully that at least gives you an idea though!

Good luck!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.