pro*_*eek 10 objective-c protocol-handler
我有一个启动一些应用程序的URLHandler,主要代码如下.
@implementation URLHandlerCommand
- (id)performDefaultImplementation {
NSString *urlString = [self directParameter];
NSLog(@"url :=: %@", urlString);
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/open"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-a", @"Path Finder.app", urlString, nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
return nil;
}
Run Code Online (Sandbox Code Playgroud)
由于此例程的目标是启动另一个应用程序,我想在启动App后使此URLHandler退出.我怎样才能做到这一点?
Yuj*_*uji 19
您不必open使用NSTask... open只需调用Launch Services,其中一些功能可直接从NSWorkspace获得.
要退出,你只需打电话[[NSApplication sharedApplication] terminate:nil].见NSApplication文档.
| 归档时间: |
|
| 查看次数: |
14289 次 |
| 最近记录: |