Skip to content

Incorporating Nodelike into your own objective C project

jeff-h edited this page Mar 7, 2014 · 2 revisions

First, attach Nodelike to a Javascript Context by NLContext#attachToContext:(JSContext *). This exposes the Node APIs to the global object of the context.

You can then execute some javascript via JSContext#evaluateScript:(NSString *).

Afterwards, you need to run the event loop via NLContext#runEventLoopSync or NLContext#runEventLoopAsync.

In the end, when you executed all scripts you wanted to, you can simulate the shutdown of the Node.js process via NLContext#emitExit:(JSContext *).

Further reading: