Apple Script works fine, but does not get the expected result with Objective-C Library

I tried running apple script

#! /usr/bin/osascript do shell script "chmod 777 /Library/ColorSync/Profiles" with administrator privileges 

It works great in the editor and terminal script. But it cannot work with Objective C. Any help would be appreciated.

 -(void)executeAppleScript{ NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: @"#! /usr/bin/osascript do shell script \"chmod 777 /Library/ColorSync/Profiles\" with administrator privileges"]; returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; } 
0
source share
1 answer

I just deleted the # command. he is working now

  -(void)executeAppleScript{ NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: @"do shell script \"chmod 777 /Library/ColorSync/Profiles\" with administrator privileges"]; returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; } 
0
source

Source: https://habr.com/ru/post/1497210/


All Articles