0
- (IBAction) charlieImputText:(id)sender {

NSAppleScript *keystrokeReturn = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to keystroke return"];
[keystrokeReturn executeAndReturnError:nil];

[progressBarText startAnimation:self];

charlieImputSelf = [sender stringValue];

NSAppleScript *sendCharlieImput = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application \"Terminal\" to do shell script  %@", charlieImputSelf]];
[sendCharlieImput executeAndReturnError:nil];

NSDictionary* errorDict;
NSAppleScript* script=[[NSAppleScript alloc] 
                       initWithContentsOfURL:[NSURL fileURLWithPath:@"/applications/jarvis/scripts/getTextCharlieResponce.scpt" ]
                       error:&errorDict];
NSAppleEventDescriptor* desc=[script executeAndReturnError:&errorDict];
NSString* result=[desc stringValue];
self.charlieOutput.stringValue = result;
charlieOutput.textColor = [NSColor greenColor];
[script release];

[progressBarText stopAnimation:self];

}

私はこれにとても慣れていないので、別の質問でこのコードの問題を投稿しましたが、誰かがこれで私に応答しました:

シェルスクリプトを実行するには、引数を引用する必要があります。

これは何を意味するのでしょうか??誰かが例を示すことができますか?

すみません、この新しい時代の用語が何を意味するのかわかりません!:D

4

1 に答える 1

0

あなたのコードには次のものがあります:

@"tell application \"Terminal\" to do shell script  %@"

これ%@が「doshellscript」コマンドの「引数」です。だから私はあなたが必要なものは次のとおりだと思います:

@"tell application \"Terminal\" to do shell script  \"%@\""
于 2010-07-03T02:19:32.797 に答える