0
我正在從我的應用程序中調用AppleScript。我的代碼的相關片段看起來像這樣:Obj-C/AppleScript語法問題
-(void)sendMail:(NSString*)addressStr
{
NSString *scriptString = <snip>
@"end tell\n"
@"tell b to make new to recipient with properties {address:\"[email protected]\"}\n"
@"send b\n"
@"end tell\n";
<snip>
}
與「硬連線」的電子郵件地址的腳本運行完美,但我真的想使用的地址我們社區的數據庫。我嘗試使用可變字符串作爲scriptString,然後在將scriptString傳遞給AppleScript對象之前,將已傳遞的addressStr插入到確切(已知)索引中。但是,如果我刪除(只)地址字符,並嘗試類似:
@"tell b to make new to recipient with properties {address:\"\"}\n"
<snip>
[scriptString insertString:addressStr atIndex:556];
...,要麼不會編譯或給出了一個「嘗試用insertString改變一個不可改變的對象(??):atIndex:」運行時出錯 - 取決於我的嘗試。
因此,無論我的語法是錯誤的(P = 0.95),還是我試圖用AppleScript做不可能的事情。任何人都可以幫我解決問題嗎?提前致謝:-)
非常感謝,Mike。它現在工作完美! 「Spasiba」:-) – Bender 2011-01-23 07:51:41