ApplesauceOS
Read Markdown ↗Download .md

ObjC.out

Prepare an object output parameter, such as NSError**.

js
ObjC.out()

Arguments

No arguments.

Returns

Box with value, initially null; updated by the native call.

Example

js
const error = ObjC.out();
const text = ObjC.call("NSString", "stringWithContentsOfFile:encoding:error:", __dirname + "/input.txt", 4, error);
try {
  if (text) console.log(text.toJS());
  else if (error.value) console.log(String(error.value));
} finally {
  if (text) text.release();
  if (error.value) error.value.release();
}

Notes

Start with Objective-C step by step. Also available on app = RemoteObjC.forApp(bundleId) as app.out(). The box is cleared before reuse. Only object output parameters are supported. The example reads a UTF-8 file (encoding 4); input.txt must exist for success. error.value is an object proxy or null, not a thrown JS exception.

Also available as

RemoteObjC.out.

All JavaScript APIs · Automation playbook