在 Applescript 中设置 属性 对象的值 Objective-C
Setting Property Value of Object in Applescript Objective-C
我正在 XCode (5) OSX 10.9.5 上工作,创建一个 ApplescriptOjbC 项目。
我在项目中创建了一个新的 applescript,其中包含一个名为 "MSDropBox" 的 class(脚本),并使用它来接受文件拖放。删除的文件已正确读取其文件路径。我现在只想将此数组传递给数组控制器,它用作 table 的源。我希望 table 反映拖动的文件。
我在 AppDelegate class 中有一个设置值的方法,我从 MSDropBox class 调用它。但是,它正在影响 table 中的值。我相信它是在调用 class 的方法,而不是对象。我如何影响对象?
下面是 MSDropBox class:
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
在Objective-C中是
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate setPageList:thisPageList];
AppleScriptObjC 等价物是
set appDelegate to current application's NSApplication's sharedApplication()'s delegate()
appDelegate's setPageList_(thisPageList)
我不确定 AppleScriptObjC 是否能识别没有类型转换的应用程序委托方法,也许你必须添加 as AppDelegate
我正在 XCode (5) OSX 10.9.5 上工作,创建一个 ApplescriptOjbC 项目。
我在项目中创建了一个新的 applescript,其中包含一个名为 "MSDropBox" 的 class(脚本),并使用它来接受文件拖放。删除的文件已正确读取其文件路径。我现在只想将此数组传递给数组控制器,它用作 table 的源。我希望 table 反映拖动的文件。
我在 AppDelegate class 中有一个设置值的方法,我从 MSDropBox class 调用它。但是,它正在影响 table 中的值。我相信它是在调用 class 的方法,而不是对象。我如何影响对象?
下面是 MSDropBox class:
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
在Objective-C中是
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate setPageList:thisPageList];
AppleScriptObjC 等价物是
set appDelegate to current application's NSApplication's sharedApplication()'s delegate()
appDelegate's setPageList_(thisPageList)
我不确定 AppleScriptObjC 是否能识别没有类型转换的应用程序委托方法,也许你必须添加 as AppDelegate