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

Jitin Jindal

macrumors newbie
Original poster
Feb 18, 2013
13
0
India
hello Friends

I have some applescript which are helping me in solving some issues i want to call these applscript through objective c code with input arguments for script.

will you please help me how can i call these scripts from objective c code?

NOTE: I also want to pass input arguments for the script.
 
One way is to run the script from inside you c using scripting bridge.
https://developer.apple.com/library...BridgeConcepts/Introduction/Introduction.html

Another way is to create a text string and then "system" it (note, I probably have the quotes a bit wrong here).
system("osascript -e \'tell app \"Address Book\" to get the name of every person\' | perl -pe \'s/, /\n/g\' | sort | uniq -d");

A third way is use NSTASK. You could check eg this page for a start on NSTASK.
http://stackoverflow.com/questions/8705381/cocoa-objective-c-shell-script-from-application


// gunnar
 
Assuming you are running at least Snow Leopard, a fourth way would be to add an AppleScriptObjC class to your project and call the desired handlers/methods from the Objective-C code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.