applescriptobjc good news for objective c coders too
play

AppleScriptObjC: Good News for Objective-C Coders, too Shane - PowerPoint PPT Presentation

AppleScriptObjC: Good News for Objective-C Coders, too Shane Stanley Myriad Communications Pty Ltd <sstanley@myriad-com.com.au> /dev/world/2010 Rydges Melbourne Inter Application Communications Getting information from other


  1. AppleScriptObjC: Good News for Objective-C Coders, too Shane Stanley Myriad Communications Pty Ltd <sstanley@myriad-com.com.au> /dev/world/2010 Rydges Melbourne

  2. Inter Application Communications • Getting information from other applications /dev/world/2010 Rydges Melbourne

  3. Inter Application Communications • Getting information from other applications • Allows treating other applications as “super frameworks” /dev/world/2010 Rydges Melbourne

  4. Inter Application Communications • Getting information from other applications • Allows treating other applications as “super frameworks” • Built on Apple events /dev/world/2010 Rydges Melbourne

  5. Inter Application Communications • Getting information from other applications • Allows treating other applications as “super frameworks” • Built on Apple events • AppleScript and Apple events were designed around each other /dev/world/2010 Rydges Melbourne

  6. Apple Events from Objective-C • NSAppleEventDescriptor & AESendMessage() (10.0) /dev/world/2010 Rydges Melbourne

  7. Apple Events from Objective-C • NSAppleEventDescriptor & AESendMessage() (10.0) • NSAppleScript (10.2) /dev/world/2010 Rydges Melbourne

  8. Apple Events from Objective-C • NSAppleEventDescriptor & AESendMessage() (10.0) • NSAppleScript (10.2) • Scripting Bridge (10.5) /dev/world/2010 Rydges Melbourne

  9. Apple Events from Objective-C • NSAppleEventDescriptor & AESendMessage() (10.0) • NSAppleScript (10.2) • Scripting Bridge (10.5) • objc-appscript (third-party) /dev/world/2010 Rydges Melbourne

  10. Apple Events from Objective-C • NSAppleEventDescriptor & AESendMessage() (10.0) • NSAppleScript (10.2) • Scripting Bridge (10.5) • objc-appscript (third-party) • AppleScriptObjC (10.6) /dev/world/2010 Rydges Melbourne

  11. AESendMessage() • Fast and efficient /dev/world/2010 Rydges Melbourne

  12. AESendMessage() • Fast and efficient, but complicated /dev/world/2010 Rydges Melbourne

  13. NSAppleScript • Simple, but slow and limited /dev/world/2010 Rydges Melbourne

  14. NSAppleScript • Simple, but slow and limited • Simple use is much slower • Doesn’t integrate well with Objective-C • Doesn’t scale well /dev/world/2010 Rydges Melbourne

  15. Scripting Bridge • Fast, efficient, simple /dev/world/2010 Rydges Melbourne

  16. Scripting Bridge • Fast, efficient, simple • Generate header file and add to project • Link to framework • Write code /dev/world/2010 Rydges Melbourne

  17. Scripting Bridge • Fast, efficient, simple • Generate header file and add to project • Link to framework • Write code • Lots of shortcomings • Incompatible with many applications /dev/world/2010 Rydges Melbourne

  18. objc-appscript • Third-party framework • Work-in-progress • Need to generate objc-appscript dictionary documentation and glue code /dev/world/2010 Rydges Melbourne

  19. AppleScriptObjC • Bridges AppleScript and Cocoa /dev/world/2010 Rydges Melbourne

  20. AppleScriptObjC • Bridges AppleScript and Cocoa • Script objects become Cocoa classes /dev/world/2010 Rydges Melbourne

  21. AppleScriptObjC • Bridges AppleScript and Cocoa • Script objects become Cocoa classes • Scripts call methods as handlers /dev/world/2010 Rydges Melbourne

  22. AppleScriptObjC • Bridges AppleScript and Cocoa • Script objects become Cocoa classes • Scripts call methods as handlers • Classes call handlers as methods /dev/world/2010 Rydges Melbourne

  23. AppleScriptObjC • Bridges AppleScript and Cocoa • Script objects become Cocoa classes • Scripts call methods as handlers • Classes call handlers as methods • Fast, easy to use /dev/world/2010 Rydges Melbourne

  24. AppleScriptObjC • Bridges AppleScript and Cocoa • Script objects become Cocoa classes • Scripts call methods as handlers • Classes call handlers as methods • Fast, easy to use • Lets languages play to their strengths /dev/world/2010 Rydges Melbourne

  25. Implementing AppleScriptObjC • Runs in 10.6 only /dev/world/2010 Rydges Melbourne

  26. Implementing AppleScriptObjC • Runs in 10.6 only • Link to framework /dev/world/2010 Rydges Melbourne

  27. Implementing AppleScriptObjC • Runs in 10.6 only • Link to framework • Insert in main.c: #import <AppleScriptObjC/AppleScriptObjC.h> [[NSBundle mainBundle] loadAppleScriptObjectiveCScripts]; /dev/world/2010 Rydges Melbourne

  28. Implementing AppleScriptObjC • Add AS class, instantiate in .xib /dev/world/2010 Rydges Melbourne

  29. Implementing AppleScriptObjC • Add AS class, instantiate in .xib • Use @class declaration, call handlers as methods (colons > underscores) /dev/world/2010 Rydges Melbourne

  30. Implementing AppleScriptObjC • Add AS class, instantiate in .xib • Use @class declaration, call handlers as methods (colons > underscores) • Use protocol to suppress compiler warnings /dev/world/2010 Rydges Melbourne

  31. AppleScriptObjC in Action AttachAScript.app (Apple sample code) and FrankenApp.app /dev/world/2010 Rydges Melbourne

Recommend


More recommend