명령 줄을 사용하여 Path Finder 응용 프로그램을 실행할 때 open -a Path Finder.app /Users/
을 사용합니다. 이 아이디어를 바탕으로 다음 코드를 사용하여 Path Finder를 시작합니다.Objective-C/Cocoa가 포함 된 Mac 응용 프로그램 시작
open
명령 줄을 사용하지 않고 앱을 시작할 수 있습니까?
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/open"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-a", @"Path Finder.app", @"/Users/", nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
매개 변수를 제공하는 방법? – prosseek
이렇게하려면 launchApplicationAtURL : options : configuration : error :를 사용해야합니다. 나는 그것을 내 게시물에 사용하는 예제를 추가 할 것이다. – ughoavgfhw
글쎄, 잘 모르겠지만, 간결함의 측면에서, 내 대답 (openFile : withApplication 사용)이 더 잘 (이해하기 쉽고 짧음) 보인다. – prosseek