This is working on my side (if you don’t care about the return value of your JS function):
Put this in a *.mm file (as a method of a NSObject subclass for instance):
- (void) callJS:(NSString *)expressionToEval {
ScriptingCore * sc = ScriptingCore::getInstance();
if (sc) {
const char * strToEval = ;
sc->evalString(strToEval, NULL);
}
}
Then call:
;
I don’t know yet if there might be thread issues. In this case I might need to wrap my ScriptingCore call in:
cocos2d::Director::getInstance()->getScheduler()->performFunctionInCocosThread(=](){ });