ApplesauceOS
Read Markdown ↗Download .md

ObjCObject.toJS

Copy Foundation values into JavaScript.

js
object.toJS()

Arguments

No arguments.

Returns

Copied Foundation data: string, boolean, number, array, plain object or null. Large integers become BigInt, or decimal strings if BigInt is unavailable.

Example

js
const text = ObjC.call("NSString", "stringWithString:", "Hello");
try { console.log(text.toJS()); } // "Hello"
finally { text.release(); }

Notes

Start with Objective-C step by step. Here, object means a proxy returned by ObjC/RemoteObjC, not a global named ObjCObject. This copies data, not every kind of native object. Unsupported objects or cyclic/deep data can throw.

All JavaScript APIs · Automation playbook