【问题标题】:Creating a new document via AppleScript results in a document with no title通过 AppleScript 创建新文档会导致文档没有标题
【发布时间】:2010-01-26 07:26:55
【问题描述】:

我正在制作一个可编写脚本的基于 Cocoa NSDocument 的应用程序。如果我尝试使用以下 AppleScript 创建一个新文档:

tell application "MyApp" to make new document

创建了一个新文档,但其标题为 nil。关于为什么会发生这种情况以及如何解决它的任何想法?

【问题讨论】:

    标签: cocoa applescript


    【解决方案1】:

    我快速浏览了 TextEdit 开发人员示例代码 (/Developer/Examples/TextEdit),看看它是否对此有所了解。 Document.m 的 -init 方法中有一条注释说:

    // Assume the default file type for now, since -initWithType:error: 
    does not currently get called when creating documents using 
    AppleScript. (4165700)
    

    这可能与问题有关吗?您是否定义了多种文档类型?

    如果不是这样,您可能需要发布您的 .scriptsuite 和 .scriptterminology 文件。

    【讨论】:

    • 这与问题有关。当我进行更改时,'告诉应用程序“MyApp”制作新文档'现在返回'应用程序“MyApp”的文档“无标题”',就像它应该的那样,但我的应用程序没有打开新窗口。如果我在 Xcode 中创建默认的 NSDocument 应用程序并启用脚本功能,这与我看到的行为相同。
    猜你喜欢
    • 2017-05-06
    • 1970-01-01
    • 2021-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 2014-08-23
    相关资源
    最近更新 更多