2010-07-03 70 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