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

applescriptobjc good news for objective c coders too
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1
slide-2
SLIDE 2

/dev/world/2010

Rydges Melbourne

Shane Stanley Myriad Communications Pty Ltd <sstanley@myriad-com.com.au>

AppleScriptObjC: Good News for Objective-C Coders, too

slide-3
SLIDE 3

/dev/world/2010

Rydges Melbourne

Inter Application Communications

  • Getting information from other

applications

slide-4
SLIDE 4

/dev/world/2010

Rydges Melbourne

Inter Application Communications

  • Getting information from other

applications

  • Allows treating other applications as

“super frameworks”

slide-5
SLIDE 5

/dev/world/2010

Rydges Melbourne

Inter Application Communications

  • Getting information from other

applications

  • Allows treating other applications as

“super frameworks”

  • Built on Apple events
slide-6
SLIDE 6

/dev/world/2010

Rydges Melbourne

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

slide-7
SLIDE 7

/dev/world/2010

Rydges Melbourne

Apple Events from Objective-C

  • NSAppleEventDescriptor &

AESendMessage() (10.0)

slide-8
SLIDE 8

/dev/world/2010

Rydges Melbourne

Apple Events from Objective-C

  • NSAppleEventDescriptor &

AESendMessage() (10.0)

  • NSAppleScript (10.2)
slide-9
SLIDE 9

/dev/world/2010

Rydges Melbourne

Apple Events from Objective-C

  • NSAppleEventDescriptor &

AESendMessage() (10.0)

  • NSAppleScript (10.2)
  • Scripting Bridge (10.5)
slide-10
SLIDE 10

/dev/world/2010

Rydges Melbourne

Apple Events from Objective-C

  • NSAppleEventDescriptor &

AESendMessage() (10.0)

  • NSAppleScript (10.2)
  • Scripting Bridge (10.5)
  • objc-appscript (third-party)
slide-11
SLIDE 11

/dev/world/2010

Rydges Melbourne

Apple Events from Objective-C

  • NSAppleEventDescriptor &

AESendMessage() (10.0)

  • NSAppleScript (10.2)
  • Scripting Bridge (10.5)
  • objc-appscript (third-party)
  • AppleScriptObjC (10.6)
slide-12
SLIDE 12

/dev/world/2010

Rydges Melbourne

AESendMessage()

  • Fast and efficient
slide-13
SLIDE 13

/dev/world/2010

Rydges Melbourne

AESendMessage()

  • Fast and efficient, but complicated
slide-14
SLIDE 14

/dev/world/2010

Rydges Melbourne

NSAppleScript

  • Simple, but slow and limited
slide-15
SLIDE 15

/dev/world/2010

Rydges Melbourne

NSAppleScript

  • Simple, but slow and limited
  • Simple use is much slower
  • Doesn’t integrate well with Objective-C
  • Doesn’t scale well
slide-16
SLIDE 16

/dev/world/2010

Rydges Melbourne

Scripting Bridge

  • Fast, efficient, simple
slide-17
SLIDE 17

/dev/world/2010

Rydges Melbourne

Scripting Bridge

  • Fast, efficient, simple
  • Generate header file and add to project
  • Link to framework
  • Write code
slide-18
SLIDE 18

/dev/world/2010

Rydges Melbourne

Scripting Bridge

  • Fast, efficient, simple
  • Generate header file and add to project
  • Link to framework
  • Write code
  • Lots of shortcomings
  • Incompatible with many applications
slide-19
SLIDE 19

/dev/world/2010

Rydges Melbourne

  • bjc-appscript
  • Third-party framework
  • Work-in-progress
  • Need to generate objc-appscript

dictionary documentation and glue code

slide-20
SLIDE 20

/dev/world/2010

Rydges Melbourne

AppleScriptObjC

  • Bridges AppleScript and Cocoa
slide-21
SLIDE 21

/dev/world/2010

Rydges Melbourne

AppleScriptObjC

  • Bridges AppleScript and Cocoa
  • Script objects become Cocoa classes
slide-22
SLIDE 22

/dev/world/2010

Rydges Melbourne

AppleScriptObjC

  • Bridges AppleScript and Cocoa
  • Script objects become Cocoa classes
  • Scripts call methods as handlers
slide-23
SLIDE 23

/dev/world/2010

Rydges Melbourne

AppleScriptObjC

  • Bridges AppleScript and Cocoa
  • Script objects become Cocoa classes
  • Scripts call methods as handlers
  • Classes call handlers as methods
slide-24
SLIDE 24

/dev/world/2010

Rydges Melbourne

AppleScriptObjC

  • Bridges AppleScript and Cocoa
  • Script objects become Cocoa classes
  • Scripts call methods as handlers
  • Classes call handlers as methods
  • Fast, easy to use
slide-25
SLIDE 25

/dev/world/2010

Rydges Melbourne

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
slide-26
SLIDE 26

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Runs in 10.6 only
slide-27
SLIDE 27

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Runs in 10.6 only
  • Link to framework
slide-28
SLIDE 28

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Runs in 10.6 only
  • Link to framework
  • Insert in main.c:

#import <AppleScriptObjC/AppleScriptObjC.h> [[NSBundle mainBundle] loadAppleScriptObjectiveCScripts];

slide-29
SLIDE 29

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Add AS class, instantiate in .xib
slide-30
SLIDE 30

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Add AS class, instantiate in .xib
  • Use @class declaration, call handlers

as methods (colons > underscores)

slide-31
SLIDE 31

/dev/world/2010

Rydges Melbourne

Implementing AppleScriptObjC

  • Add AS class, instantiate in .xib
  • Use @class declaration, call handlers

as methods (colons > underscores)

  • Use protocol to suppress compiler

warnings

slide-32
SLIDE 32

/dev/world/2010

Rydges Melbourne

AppleScriptObjC in Action

AttachAScript.app (Apple sample code) and FrankenApp.app