mac 中启动另外一个程序并且将该窗口置于最前面

- (void)launchSoftWithBundleID:(NSString *)softPath
{
    NSBundle *softBundle = [NSBundle bundleWithPath:softPath];
    NSString *bundleID = [softBundle bundleIdentifier];
    //运行程序
    NSTask *softTask = [[NSTask alloc] init];
    [softTask setLaunchPath:softPath];
    [softTask launch];
    //得到运行的程序,并置于最前面
    NSArray *array = [NSRunningApplication runningApplicationsWithBundleIdentifier:bundleID];
    if ([array count] > 0)
    {
        NSRunningApplication *runningApp = [array objectAtIndex:0];
        [runningApp activateWithOptions:NSApplicationActivateIgnoringOtherApps];
    }
}

你可能感兴趣的:(Mac,OS,mac)