【发布时间】:2016-04-02 17:43:23
【问题描述】:
我正在使用 OSX 10.9.5 上的 XCode (5) 创建一个 ApplescriptOjbC 项目。
我在项目中创建了一个新的applescript,其中包含一个名为“MSDropBox”的类(脚本),并使用它来接受文件的删除。删除的文件的文件路径读取正确。我现在只想将此数组传递给数组控制器,它用作表的源。我希望表格反映拖动的文件。
我在 AppDelegate 类中有一个设置值的方法,我从 MSDropBox 类中调用它。但是,它会影响表中的值。我相信它正在调用类的方法,而不是对象。我如何影响对象?
下面是 MSDropBox 类:
script MSDropBox
property parent : class "NSBox"
property window : missing value
property thisPageList : missing value
on draggingEntered_(sender)
log "entered"
set pb to sender's draggingPasteboard()
set theOptions to {NSPasteboardURLReadingFileURLsOnlyKey:1}
return pb's canReadObjectForClasses_options_({current application's |NSURL|}, theOptions)
end draggingEntered_
on performDragOperation_(sender)
log "perform"
-- Get the file paths
set pb to sender's draggingPasteboard()
set theOptions to {NSPasteboardURLReadingFileURLsOnlyKey:1}
set theURLs to pb's readObjectsForClasses_options_({current application's |NSURL|}, theOptions)
log theURLs
repeat with thisURL in theURLs
set thisURLStr to (characters 1 thru -1 of ((thisURL's |path|()) as string) as string)
set thisPageList to thisPageList & thisURLStr as list
end repeat
return true
end performDragOperation_
on concludeDragOperation_(sender)
log "concludeDragOperation_"
tell class "AppDelegate" of current application
setPageList_(thisPageList)
end tell
end concludeDragOperation_
end script
【问题讨论】:
标签: xcode macos xcode5 nstableview applescript-objc