osx - Pass Variable or String from OS X Cocoa App to Applescript -


i pass variable applescript. example, type words in textfield of cocoa-app (not cocoa-applescript app).then, variable in applescript future use. use applescript tell software run files.

i've tried how can pass string applescript objective c method here. add first lines in applescript using initialwithsource. have write long sentence. if i've have applescript, have either combine them together. or have write script in cocoa below. it's meaningless , doesn't work well.

nsstring *slideurl = [nsstring stringwithformat:@"set mypath \"%@\" \n tell application \"keynote\" \n open mypath \n tell slideshow %@ \n start slideshow\n end tell \n end tell\n",temp,temp];  // here meaningless right // temp variable want pass applescript   nsdictionary *errorinfo = nil; nsapplescript *script = [[nsapplescript alloc] initwithsource:slideurl]; [script executeandreturnerror:&errorinfo]; [script release]; 

do of know better way ?

thanks

string mashing evil. use applescriptobjc; there's no magic or complexity it.

assuming application built using cocoa application template, need 1. include applescriptobjc framework in project , 2. modify main.m match asoc template's main.m, contains 2 lines:

#import <cocoa/cocoa.h>  #import <applescriptobjc/applescriptobjc.h>  int main(int argc, char *argv[]) {     [[nsbundle mainbundle] loadapplescriptobjectivecscripts];     return nsapplicationmain(argc, (const char **)argv); } 

once you've done that, can add asoc-style script object files project , they'll native classes rest of objc program, e.g.:

-- footest.applescript  script footest     property parent : class "nsobject"      on dosomething_(sender)         display dialog "hello world"     end   end script 

see this answer useful links.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -