I am working on a project where the good old Apple Script is need to do some magic on a Mac computer. Even though it is very semantic it can do some powerful stuff. The result will be posted as soon as it is finished.
Here is a simle Hello World example just to get it up and running in Xcode. The example is used in a Mac OS X application.
@implementation S46AppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSDictionary* errorDict;
NSAppleEventDescriptor* returnDescriptor = NULL;
NSAppleScript* scriptObject = [[NSAppleScriptalloc] initWithSource:
@"display dialog \"Hello World\" buttons \"OK\" default button \"OK\""
];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
[scriptObject release];
if (returnDescriptor != NULL)
{
// successful execution
if (kAENullEvent != [returnDescriptor descriptorType])
{
// script returned an AppleScript result
if (cAEList == [returnDescriptor descriptorType])
{
// result is a list of other descriptors
}
else
{
// coerce the result to the appropriate ObjC type
}
}
}
else
{
// no script result, handle error here
}
}
@end





