Skip to content

A few utilities for interacting with handlers in NSAppleScript.

Notifications You must be signed in to change notification settings

elijah-santos25/applescript-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AppleScriptUtil

Utilities for interacting with NSAppleScript in Swift.

Included Utilities

  • fourCharCode(_:) - creates a FourCharCode from a 4-character ASCII string.
  • NSAppleScript.rawHandler(named:) - returns a closure that invokes a handler in the script with NSAppleEventDescriptor argument and return value.
  • Typed handlers:
    • NSAppleEventDescriptorConvertible - a protocol for types that can be converted two-way into and from NSAppleEventDescriptor
    • NSAppleScript.handler(named:argumentTypes:returnType:) (and its Void-return equivalent) - returns a closure that invokes a handler in the script with typed argument and return values.

Usage Example

let source = """
to cube(theNumber)
  return theNumber * theNumber * theNumber
end cube
"""
let script = NSAppleScript(source: source)!
let cube: (Double) throws -> Double = script.handler(named: "cube") // argument types inferred

print(try cube(3))

About

A few utilities for interacting with handlers in NSAppleScript.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages