我尝试使用launchApplicationAtURL.运行等效的"TextMate foo.txt“。二进制名为"TextMate",我有一个参数。
我尝试了下面的代码,但似乎不起作用。
// find the textmate
NSURL * bURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.macromates.textmate"];
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
// find the parameter
NSString * f = @"foo.txt";
NSArray * myArray2 = [NSArray arrayWithObjects:f,nil];
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
[dict setObject:myArray2 forKey:NSWorkspaceLaunchConfigurationArguments];
[ws launchApplicationAtURL:bURL options:NSWorkspaceLaunchDefault configuration:dict error:nil];这是怎么回事?
已添加
我检查了这段代码的实际工作情况,我发现“TextMate.app”处理参数的方式有问题。
发布于 2010-07-26 04:51:08
大多数应用程序不使用命令行参数。如果您想用特定的应用程序打开特定的文件,请使用-[NSWorkspace openFile:withApplication:]。
https://stackoverflow.com/questions/3332049
复制相似问题