0

NSTaskを介して以下のtopsコマンドを使用しようとしています。

tops replace "__My_CompanyName__" with "XYZ" TryItOut.m

しかし、それは常に以下のエラーを与えています:

File replace "__My_CompanyName__" with "XYZ" does not exist

ターミナルを介して実行すると、正常に動作します。

以下は私が使用したコードです:

NSTask *theTopsCommand = [[NSTask alloc] init];
[theTopsCommand setLaunchPath:@"/usr/bin/tops"];
[theTopsCommand setArguments:[[NSArray alloc] initWithObjects:@"replace \"__My_CompanyName__\" with \"XYZ\"", self.selectedFilePath,nil]];
[theTopsCommand launch];
[theTopsCommand waitUntilExit];

私が何か間違ったことをした場合、誰かが私を提案できますか?

4

1 に答える 1

1

引数を文字列の配列として提供する必要がありtopsますが、1つの単一の文字列を提供しています。

試す:

[theTopsCommand setArguments:[NSArray arrayWithObjects:@"replace", @"__My_CompanyName__", @"with", @"XYZ", self.selectedFilePath, nil]];
于 2012-09-10T07:13:39.727 に答える