Вопрос

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

}

Я такая новичка к этому, и я разместил проблему с этим кодом в другой вопрос, и кто-то ответил мне с этим:

Вам нужно процитировать аргумент, чтобы сделать сценарий оболочки.

Что это значит?? Может кто-нибудь показать пример ??

Я оооочень извините, я понятия не имею, что означает этот новой возраст Lingo! : D.

Это было полезно?

Решение

В вашем коде у вас есть:

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

Это %@ Является ли «аргумент» команды «Do Shell Script». Так что я думаю, что вам нужно:

@"tell application \"Terminal\" to do shell script  \"%@\""
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top