Applescript-able Cocoa:引用对象的 NSArray?
Posted
技术标签:
【中文标题】Applescript-able Cocoa:引用对象的 NSArray?【英文标题】:Applescript-able Cocoa : Reference to NSArray of objects? 【发布时间】:2012-04-06 04:56:53 【问题描述】:好的。所以,让我们说:
我有一个类myCollection
,一个类myObject
和一个属性objects
在myCollection
返回一个NSArray
的myObject
s
鉴于我已经为myCollection
和myObject
类正确设置了我的.sdef
文件,我应该如何在那里定义我的objects
属性?
我的意思是,到目前为止我可以做这样的事情:
tell application "myApplication"
collection's activeObject's name
end tell
我想要的是能够以数组元素的形式访问myObject
s:
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'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】:这就是我所需要的:
<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"/>
....
【讨论】:
以上是关于Applescript-able Cocoa:引用对象的 NSArray?的主要内容,如果未能解决你的问题,请参考以下文章
Cocoa/如何在应用程序委托中获取对当前窗口的 contentViewController 的引用?