js直接调用oc代码

oc代码:(新建一个A.h和A.mm文件)

//@class RootViewController;
@interface UmengUtil : NSObject{
    
}
+(void)pushA:(NSString*)name;  //自定义事件
+(void)pushB:(NSString*)name param:(NSString*)ext;  //自定义事件

@end

js代码:

if (cc.sys.os == cc.sys.OS_IOS) {
    let name = 'xx'
    let ext = 'xxxx'
    jsb.reflection.callStaticMethod("A", "pushA:",name);
    jsb.reflection.callStaticMethod("A","pushB:param:", name,ext);   
        }

你可能感兴趣的:(js直接调用oc代码)