2010-07-03 71 views
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]; 

} 

我這樣一個新手到這一點,我在另一個問題發佈了一個問題,此代碼,有人回答我這個:報價參數

你需要引用的說法做的shell腳本。

這是什麼意思?有人可以舉個例子嗎?

我SOOOO對不起,我不知道這是什麼新時代的行話指! :d

+0

而不是發佈一個新的問題,你應該最好發表評論給誰回答,問他們的意思。的99%的時候,他們會很樂意澄清,只要你努力去澄清什麼你不理解等等:) – Kalle 2010-07-03 09:50:52

+0

哦....對不起...我是新來這個地方。如果發佈新評論,他們是否會收到電子郵件通知? – objectiveccoder001 2010-07-03 12:29:37

回答

0

在你的代碼有:

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

%@是 「做shell腳本」 命令 「的說法」。所以我想你需要的是:

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

好的,謝謝!它仍然沒有工作,雖然.... :( 任何想法? – objectiveccoder001 2010-07-03 02:26:25

+0

「不工作」是一點點模糊。它在哪裏去了?如果第一個'executeAndReturnError'步驟失敗,那麼你不應該」 T爲傳遞零到它。你想看到錯誤信息。 – JWWalker 2010-07-03 02:34:27

+0

好吧,我知道了!用戶錯誤...對不起...愛這個地方,但... – objectiveccoder001 2010-07-03 12:28:50