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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -