Applescript-able Cocoa:引用NSArray对象?

时间:2012-04-06 04:56:54

标签: objective-c cocoa applescript scriptable sdef

行。所以,让我们说:

  • 我在myCollection中有一个myObject课程,一个课程objects和一个myCollection媒体,返回NSArraymyObject

鉴于我已为.sdefmyCollection类正确设置了myObject文件,我该如何定义我的objects属性呢?

我的意思是,到目前为止,我可以做类似的事情:

tell application "myApplication"
     collection's activeObject's name
end tell

我想要的是能够作为数组的元素访问myObject

tell application "myApplication"
     set Obj to collection's object 0
end tell

到目前为止,这是我的.sdef(差不多......):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary xmlns:xi="http://www.w3.org/2003/XInclude">
    <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>
    <suite name="myApplication Suite" code="myRm" description="myApplication Suite">
        <class name="application" code="camy" description="myApplication&apos;s top-level scripting object." inherits="application">
            <cocoa class="myApplication"/>
            <property name="myname" code="PEnm" description="The name of the application" type="text" access="r">
                <cocoa key="myname"/>
            </property>
            <property name="currentContents" code="PEnc" description="The current contents" type="text" access="r">
                <cocoa name="currentContents" />
            </property>
            <property name="activeDocument" code="PEad" description="The active document" type="document" access="r">
                <cocoa name="activeDocument" />
            </property>
        </class>
        <class name="document" code="cDoc" description="myApplication document">
            <cocoa class="myDocument"/>
            <property name="alias" code="cDal" description="The document's alias" type="text" access="r">
                <cocoa key="alias" />
            </property>
            <property name="content" code="cDco" description="The document's content" type="text" access="rw">
                <cocoa key="content" />
            </property>
        </class>
    </suite>

</dictionary>

我应该怎么做?

1 个答案:

答案 0 :(得分:0)

这就是我所需要的:

    <class name="editor" code="cDed" description="myEditor">
        <cocoa class="myEditor"/>
        <element type="document" access="r">
            <cocoa name="documents" />
        </element>
    </class>
    <class name="document" code="cDoc" description="myDocument">
        <cocoa class="myDocument"/>
        ....