Apple Script working fine but with Objective C Library not getting expected out put

浪尽此生 提交于 2020-01-09 08:17:06

问题


I tried running apple script

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

It perfectly working in script editor and terminal. But not able to run with Objective C. Any help will 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];
}

回答1:


I just removed #command. it 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];
}


来源:https://stackoverflow.com/questions/34880124/apple-script-working-fine-but-with-objective-c-library-not-getting-expected-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!