i've been playing around with applescript in cocoa lately, and it seems that some scripts tend to lag more than others. i have a script that toggles autohide of the dock and it works, the problem is that if i just started the app, this script lags, even spins out before executing:
is there something wrong with the way i wrote it?
also, is it safe to say that anything applescript can do, cocoa can also do natively without the need to embed applescript?
Code:
- (IBAction)showDock:(id)sender
{
NSString *showDockScript = @"\
tell application \"System Events\"\n\
tell dock preferences\n\
set properties to {autohide:false}\n\
end tell\n\
end tell";
NSDictionary* errorDict;
NSAppleEventDescriptor *returnDescriptor = NULL;
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:showDockScript];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
[NSAppleScript release];
}
is there something wrong with the way i wrote it?
also, is it safe to say that anything applescript can do, cocoa can also do natively without the need to embed applescript?