Couldn't call Objective-C method from Cocos-2d via JavaScriptObjCBridge

URL : https://github.com/cocos-creator/creator-docs/blob/master/en/advanced-topics/oc-reflection.md

Above is the documentation to call a Objective-C method from Cocos script

I trying to do the exact same thing, but I get the error

2020-07-21 15:56:01.094441+0800 hello_world-mobile[63684:4206926] TestingLogging.testingIntegration method isn't found!
[ERROR] (/Applications/CocosCreator/Creator/2.3.3/CocosCreator.app/Contents/Resources/cocos2d-x/cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.mm, 418): call (TestingLogging.testingIntegration) failed, result code: -3
[ERROR] Failed to invoke JavaScriptObjCBridge_callStaticMethod, location: /Applications/CocosCreator/Creator/2.3.3/CocosCreator.app/Contents/Resources/cocos2d-x/cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.mm:427

Screen Shot 2020-07-21 at 4 05 36 PM

.h class

//
//  TestingLogging.h
//  hello_world-mobile
//
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface TestingLogging : NSObject

+(void) testingIntegration: (NSString *) string;

@end

NS_ASSUME_NONNULL_END

.m class

//
//  TestingLogging.m
//  hello_world-mobile
//
//

#import "TestingLogging.h"

@implementation TestingLogging


+(void)testingIntegration:(NSString *)string {
    NSLog(@"First ios call from cocos creator app %@", string);
}

@end

Script in cocos

onCameraClickHandler () {
    if(cc.sys.OS_IOS == cc.sys.os) {           
        var ret = jsb.reflection.callStaticMethod("TestingLogging", "testingIntegration", "Hello iOS")
    }
}

Could you please help me !

oc的我不太懂,就问一下,这样调用方法,不需要实例化这个类吗?这是个static方法吗?

onCameraClickHandler () {
if(cc.sys.OS_IOS == cc.sys.os) {
var ret = jsb.reflection.callStaticMethod(“TestingLogging”, “testingIntegration”, “Hello iOS”)
}
}
以上是你调用OC那边的静态方法,这里调用不到的原因是,JS的方法名是"testingIntegration",而不是"testingIntegration:",JS调用OC是需要添加上":"的,这里是单参数,如果两个参数以上也是需要把参数2的名称添加上去,如下
OC:
+(void)testingIntegration:(NSString *)string agr1 _arg2:(NSString *)string arg2{
NSLog(@“First ios call from cocos creator app %@”, string);
}
JS:
jsb.reflection.callStaticMethod(“TestingLogging”, “testingIntegration:_arg2:”, “Hello iOS”,“Me too”)