0
votes

I am trying to use below tops command through NSTask:

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

but it is always giving below error:

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

When executed through terminal it works fine.

Below is the code, which I used:

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];

Can anyone suggest me, if I did anything wrong?

1

1 Answers

1
votes

You need to provide the arguments to tops as an array of strings, but you are providing one single string.

Try:

[theTopsCommand setArguments:[NSArray arrayWithObjects:@"replace", @"__My_CompanyName__", @"with", @"XYZ", self.selectedFilePath, nil]];