Scripting bridge: within AppleScriptObjC code, allow casting a scripting bridge object to its AppleScript equivalent
| Originator: | amorya | ||
| Number: | rdar://19397003 | Date Originated: | 07-Jan-2015 10:39 AM |
| Status: | Open | Resolved: | |
| Product: | OS X SDK | Product Version: | |
| Classification: | Enhancement | Reproducible: | Always |
Sometimes I want to drop down to AppleScriptObjC. AppleScriptObjC has its own issues (mainly related to tooling: Xcode is nowhere near as good at handling AppleScript code as it is ObjC), but some things are just easier to do in Applescript. My normal use case is to make a new class in ASOC, write a method that does the processing I want, then call that method from my ObjC code, passing in parameters to give it data. For example, this method definition: on moveTaskID_toProjectID_(taskID, projectID) tell application "OmniFocus" set myTask to task id (taskID as string) of default document set myProj to project id (projectID as string) of default document if myTask's containing project ≠ myProj then move myTask to end of tasks of myProj end if end tell end moveTaskID_toProjectID_ As you can see, in the above method I’m taking IDs as strings, and using those strings to obtain the AppleScript objects I want. There should be bridging between Scripting Bridge and AppleScriptObjC objects. For example, I should be able to have a Scripting Bridge object of class OmniFocusTask (let’s call it ofTask), pass it into an AppleScriptObjC method, then do this: set myTask to (ofTask as task) And it would magically convert the Cocoa Scripting Bridge object into the native AppleScript object it represents. This would make things SOOO much easier when writing mixed Cocoa and Applescript applications! (Actually, the problem is more than just convenience. OmniFocus supports object IDs, but apps like Mail do not, so I can’t even use this workaround.) Casting the other way would also be lovely.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!