I'm having trouble escaping a path containing spaces using NSApplescript:
// mybashscript is in the bundle app (NSlog grant that is ok!)
NSDictionary*errorDict = nil;
NSAppleScript*mycommand;
NSString *mycommand = [mybashscript stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
// NSString *mycommand = [[mybashscript stringByReplacingOccurrencesOfString:@" " withString:@"\\ "] stringByReplacingOccurrencesOfString:@"/" withString:@":"]; // another test made
mycommand = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", escapedPath]];
NSAppleEventDescriptor *eventDescriptor = [sudoPandoraMaker executeAndReturnError: &errorDict];
if (([eventDescriptor descriptorType]) && (errorDict==nil)) {
// if error is nil....is ok.. not this case :-(
} else {
NSLog(@"escapedPath รจ:%@", escapedPath);
// what's was wrong???
}
the above code works well only when the app is in paths that do not contain spaces, but when it is moved into folders or hard drives that contain spaces in their name, NSAppleScript fails. Any suggestion? Thanks