2014-09-10 4 views
0

내 NSApplication에서는 버튼이 있습니다. 그것을 클릭하면 데몬/에이전트를 시작/시작하고 싶습니다. 어떻게하면됩니까? 나는 이미 시도했다 : 어떤 성공NSApplication에서 launchd 에이전트/데몬을 실행하는 방법은 무엇입니까?

- (void) runAgent { 
    NSTask *task = [[NSTask alloc] init]; 
    task.launchPath = @"launchctl load /System/Library/LaunchAgents/com.mycompany.myagent.plist"; 
    [task setLaunchPath:@"/bin/sh"]; 
    [task launch]; 
} 

...

답변

1
NSTask *task = [[NSTask alloc] init]; 
    [task setLaunchPath:@"/bin/launchctl"]; 
    [task setArguments:[NSArray arrayWithObjects:@"load",@"/System/Library/LaunchAgents/com.mycompany.myagent.plist", nil]]; 
    [task launch]; 
관련 문제