object.name = 'Sketch'
:are converted to
_, the last underscore is optional.
- Calling a method with an underscore requires you to double up:
- Each component of the selector is concatenated into a single string with no separation.
MOPointer, a proxy object to create references from variables.
let str = NSMutableString.alloc().init() let pointer = MOPointer.alloc().initWithValue(str) str.setString('Hello Sketch') console.log(pointer.value()) str.appendString(' 👋') console.log(pointer.value())
Use macOS Frameworks
To use a macOS framework, it needs to be imported first. Please note that Foundation and CoreGraphics are imported by default.
framework('AVFoundation') let url = NSURL.alloc().initWithString( 'https://cdn.sketchapp.com/assets/pages/home/prototyping-video1.mp4' ) let asset = AVAsset.assetWithURL_(url) console.log(asset)
Read more about how to use CocoaScript and macOS frameworks.
README, please note that Mocha is now included in CocoaScript but the documentation remained on the original repository.
- Apple Developer Documentation
- Not a hotdog — how to build an AI powered plugin for Sketch 🌭