基础原理

方法调用

// 引用自[JSPatch 实现原理详解]
require('UIView')
var view = UIView.alloc().init()
view.setBackgroundColor(require('UIColor').grayColor())
view.setAlpha(0.5)
  {
  __clsName: "UIView"
  }
var _methodFunc = function(instance, clsName, methodName, args, isSuper, isPerformSelector) {
  ...
  var ret = instance ? _OC_callI(instance, selectorName, args, isSuper):
                       _OC_callC(clsName, selectorName, args)
  return _formatOCToJS(ret)
}

参考