2011-02-19 19 views
8

我有一個URLHandler啓動一些應用程序,主要代碼如下。如何在Objective-C應用程序中退出?

@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; 
} 

把此程序的目標是啓動其他應用程序,我想使這個URLHandler啓動應用程序後退出。我怎樣才能做到這一點?

回答

1

這裏已經回答了這個問題:Proper way to exit iPhone application?但是你也應該看看August的答案。儘管這不是被接受的答案,但它已經被選爲更高的選擇,並且它也遵循蘋果公司建議的標準,因爲蘋果建議不要強行停止iPhone應用程序。

+1

實際上,這是一個Mac應用程序,而不是iPhone應用程序。 – prosseek 2011-02-19 04:22:23

+0

啊我明白了。對不起假設。 – aiham 2011-02-19 04:24:49