[英]Objective c quotes and variables
我正在尝试做这样的事情:
NSAppleScript *sendCharlieImput = [[NSAppleScript alloc] initWithSource:@"tell application \"terminal\" to do script " charlieImputSelf " in front window"];
[sendCharlieImput executeAndReturnError:nil];
变量charlieImputSelf将作为命令放入终端窗口。 但是我需要将charlieImputSelf放在2个qoutes之间(如上)。 这显然不是正确的方法。 有人可以帮忙吗?
谢谢! 以利亚
使用NSString
的+stringWithFormat:
方法:
NSAppleScript *sendCharlieImput = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application \"Terminal\" to do script %@ in front window", charlieImputSelf]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.