Reputation: 3
I am working in XCode (5) on OSX 10.9.5, creating an ApplescriptOjbC project.
I have created a new applescript in the project with a class (script) named "MSDropBox" and am using it to accept the drop of files. The files dropped have their file paths read correctly. I now just want to pass this array off to the Array Controller, which is used as the source for a table. I want the table to reflect the dragged files.
I have a method in the AppDelegate class that sets the value and I am calling it from the MSDropBox class. However, it is affecting the values in the table. I believe it is calling on the method of the class, but not object. How do I affect the object?
Below is the 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
Upvotes: 0
Views: 1065
Reputation: 285180
In Objective-C it's
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate setPageList:thisPageList];
The AppleScriptObjC equivalent is
set appDelegate to current application's NSApplication's sharedApplication()'s delegate()
appDelegate's setPageList_(thisPageList)
I'm not sure whether AppleScriptObjC recognizes the application delegate method without type casting, maybe you have to add as AppDelegate
Upvotes: 1