首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“告诉应用程序'Mail'”在AppleScript-ObjC应用程序中不会接受来自IBOutlet的字符串。

“告诉应用程序'Mail'”在AppleScript-ObjC应用程序中不会接受来自IBOutlet的字符串。
EN

Stack Overflow用户
提问于 2018-06-10 19:41:52
回答 1查看 68关注 0票数 0

我正在开发一个在Mail中生成电子邮件的AppleScript-ObjC应用程序。我的UI有三个IBOutlets (两个文本字段和一个弹出菜单),用户可以在其中输入将被填充到电子邮件中的文本。我可以将这些输出中的值保存到变量中,但是当我试图在tell应用程序"Mail“语句中使用这些变量时,我会得到以下错误:

AppleEvents:接收mach,它不是getMemoryReference中所期望的复杂类型。

下面是日志中的指纹:

代码语言:javascript
复制
(
    "<NSAppleEventDescriptor: 'ctxt'>",
    ": ",
    "Status: MyProjectName, Part No.: 12345"
)

看来ctxt (我认为是NSString)和AppleScript字符串有区别,但我不知道如何转换为AppleScript字符串。如果你知道了,请告诉我。

下面是整个函数的代码:

代码语言:javascript
复制
-- IBOutlets
property theWindow : missing value
property statusMenu : missing value
property partNumberField : missing value
property projectNameField : missing value

on generateButtonClicked:sender
    set projectName to projectNameField's stringValue() as text
    set partNumber to partNumberField's stringValue() as text
    set status to statusMenu's objectValueOfSelectedItem as text

    set theSubject to (status & ": " & projectName & ", Part No.: " & partNumber) as string
    log (class of theSubject) & ": " & theSubject

    tell application "Mail"
        try
            set newMessage to make new outgoing message with properties {subject: theSubject, theContent: "", visible: true}
        on error e
            log e
        end try
        activate
    end tell
end generateButtonClicked:
EN

回答 1

Stack Overflow用户

发布于 2018-06-12 08:18:20

代码语言:javascript
复制
set newMessage to make new outgoing message ¬
    with properties {subject: theSubject, theContent: "", visible: true}

theContent不是outgoing message的属性。将其更改为content

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50787424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档