JSB: how to properly call javascript function from objective c code?

with iOS, How to properly call javascript function from objective c?

I know eventually, we call this:
NSString *jscode=“console.log(‘something’);”;
BOOL tf= se::ScriptEngine::getInstance()->evalString([jscode UTF8String]);

but I am wondering whether we need the following? as this is not documented in official documents:

cocos2d::Director::getInstance()->getScheduler()->performFunctionInCocosThread(sendMsgToCocosJs);
with cocos creator 2.2

  std::shared_ptr<Scheduler> scheduler=Application::getInstance()->getScheduler();
      scheduler->performFunctionInCocosThread(sendMsgToCocosJs);

since Director is hidden.

anyone has any idea? thanks.

include SeApi.h,

#include <cocos/scripting/js-bindings/jswrapper/SeApi.h>

then use this function:

    -(void) evalString:(NSString *)str
    {
        std::string *string = new std::string([str UTF8String]);
        const char *p = string->c_str();
        se::ScriptEngine::getInstance()->evalString(p);
    }

thanks, but clearly from my question, I know what you said.
what I am asking is: do we need to do that in cocos thread?

thanks for your time and your effort.

don’t need to that