I'm trying to run an applescript inside my Cocoa app using the system(); function - the string I'm passing to the function works in terminal and the applescript itself is fine, I think it has something to do with NSString - can anyone help?
//add to login items
NSLog(@"add to login");
NSString *pathOfApp = [[NSBundle mainBundle] bundlePath];
NSString *theASCommandLoginItem = [NSString stringWithFormat:@"/usr/bin/osascript -e 'tell application \"System Events\" to make login item at end with properties {path:\"%@\"}'", pathOfApp];
system(theASCommandLoginItem);
NSLog(theASCommandLoginItem);
Here is the output:
2009-10-11 20:09:52.803 The Talking Cloud Notifier[3091:903] add to login sh: \340HH: command not found 2009-10-11 20:09:52.813 The Talking Cloud Notifier[3091:903] /usr/bin/osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Users/csmith/Desktop/The Talking Cloud Notifier/build/Debug/The Talking Cloud Notifier.app"}'
At compile I also get a warning saying:
warning: passing argument 1 of 'system' from incompatible pointer type