objective c - Force quit OS X app -


which best way force quit os x or daemon process if know app/daemon name (the name appears in activity monitor)?

i using objective c coding.

you may use applescript that:

//tell application quit nsapplescript* restartapp = [[nsapplescript alloc] initwithsource:@"tell application \"applicationname\" quit"]; [restartapp executeandreturnerror:nil]; 

if app not responding may try

// define command nsstring* appname = @"finder"; nsstring* killcommand = [@"/usr/bin/killall " stringbyappendingstring:appname];  // execute shell command nstask *task = [[nstask alloc] init]; [task setlaunchpath:@"/bin/bash"]; [task setarguments:@[ @"-c", killcommand]]; [task launch]; 

which kills app.

good luck


Comments

Popular posts from this blog

java - Unable to make sub reports with Jasper -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -

Save and close a word document by giving a name in R -