One Quickie


Running a pre-canned applescript (AppleScript->General)
Here's a way to run a 'fire and forget' Applescript that lives in your application bundle.
#define runScriptName @"checknewnow"
#define runScriptType @"scpt"


- (IBAction)runScript:(id)sender
{
    /* Locate that darn thing*/
    NSString *scriptPath = [[NSBundle mainBundle]
                               pathForResource: runScriptName
                               ofType: runScriptType];
    NSURL *scriptURL = [NSURL fileURLWithPath: scriptPath];

    NSAppleScript *as = [[NSAppleScript alloc]
                            initWithContentsOfURL: scriptURL
                            error: nil];
    [as executeAndReturnError: NULL];
    [as release];
}
(Thanks to of Chris "The_Tick" Forsythe)



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com