开发者

Obj-C/AppleScript syntax problem

I'm calling an AppleScript from inside my application. The relevant snippet of my code looks like so:

-(void)sendMail:(NSString*)addressStr
    {
    NSS开发者_运维百科tring *scriptString = <snip>
    @"end tell\n"   
    @"tell b to make new to recipient with properties {address:\"someone@somewhere.com\"}\n"
    @"send b\n"
    @"end tell\n";
    <snip>
}

The script with "hard-wired" email address runs perfectly, but I really want to use addresses out of our community database. I tried using a mutable string for the scriptString, then inserting the passed addressStr into it at an exact (known) index before passing scriptString to the AppleScript object. But if I remove (only) the address chars and try something like:

@"tell b to make new to recipient with properties {address:\"\"}\n"
<snip>
[scriptString insertString:addressStr atIndex:556];

...it either won't compile or gives an "Attempt to mutate immutable object (??) with insertString:atIndex:" error at runtime -- depending on what I try.

So either my syntax is wrong (P=0.95), or I'm trying to do the impossible with AppleScript. Can anyone help me out, please? Thanks a lot in advance :-)


You need to use [NSString stringWithFormat:@"... %@ ...", @"arg"].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜