玩玩RN--4 RCTModuleData

2018-03-28  本文已影响0人  徰戰風雲

今天讲这个类,这个类是一个可以算是一个RCTModule 的数据储存类

instance 是有我们的extraModule 传入的 或者是 通过 new 方法sdk自己创建的

methods 这个我们可以看下他的实现

  for (unsigned int i = 0; i < methodCount; i++) {
        Method method = methods[i];
        SEL selector = method_getName(method);
        if ([NSStringFromSelector(selector) hasPrefix:@"__rct_export__"]) {
          IMP imp = method_getImplementation(method);
          auto exportedMethod = ((const RCTMethodInfo *(*)(id, SEL))imp)(_moduleClass, selector);
          id<RCTBridgeMethod> moduleMethod = [[RCTModuleMethod alloc] initWithExportedMethod:exportedMethod
                                                                                 moduleClass:_moduleClass];
          [moduleMethods addObject:moduleMethod];

遍历这个module类的方法 把所有__rct_export_开头的方法都加入到methods里面去。

上一篇 下一篇

猜你喜欢

热点阅读