Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JSPatch Introduction

Wei Wang
August 06, 2015

JSPatch Introduction

Wei Wang

August 06, 2015
Tweet

More Decks by Wei Wang

Other Decks in Programming

Transcript

  1. +BWB4DSJQU$PSF var num = 5 + 5 var triple =

    function(value) { return value * 3} triple(num) //30 import JavaScriptCore let context = JSContext() context.evaluateScript("var num = 5 + 5") context.evaluateScript("var triple = function(value) { return value * 3 }") let tripleNum: JSValue = context.evaluateScript("triple(num)") +BWB4DSJQU 4XJGU
  2. import JavaScriptCore let context = JSContext() context.evaluateScript("var num = 5

    + 5") context.evaluateScript("var triple = function(value) { return value * 3 }") let tripleNum: JSValue = context.evaluateScript("triple(num)") 1MBJO4USJOH'VODUJPOBMJUZ
  3. import JavaScriptCore let context = JSContext() context.evaluateScript("var num = 5

    + 5") context.evaluateScript("var triple = function(value) { return value * 3 }") let tripleNum: JSValue = context.evaluateScript("triple(num)") 1MBJO4USJOH'VODUJPOBMJUZ 3VOUJNF
  4. 3VMFEFpOF$MBTT w Ϋϥεͷϝιʔυ࠶ఆٛ defineClass("ClassName", { method: function() { ... },

    }) @implementation ClassName -(void)method { … } defineClass(classDeclaration, instanceMethods, classMethods)
  5. 3VMFΞϯμʔόʔ w ΫϥεͷεϖʔεΛࠩ͠ସ͑Δ @implementation JPTestObject - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    { } @end defineClass("JPTableViewController", { tableView_didSelectRowAtIndexPath: function(tableView, indexPath) { ... }, })
  6. 3VMF03*( w 03*(Λ෇͍ͨΒɺલͷ࣮૷ΛݺͿ @implementation JPTableViewController - (void) viewDidLoad { }

    @end defineClass("JPTableViewController", { viewDidLoad: function() { self.ORIGviewDidLoad(); }, })
  7. 3VMFTFUUFSHFUUFS w TFUUFSPSHFUUFSΛ࢖͏ @interface JPTableViewController @property (nonatomic) NSArray *data; @end

    @implementation JPTableViewController @end defineClass("JPTableViewController", { viewDidLoad: function() { var data = self.data() self.setData(data.toJS().push("JSPatch") }, })
  8. 4XJGU w /40CKFDUͱγεςϜ"1*0, EZOBNJD EJTQBUDI  w ଞͷ͸EZOBNJDLFZXPSEΛ௥Ճඞཁ SVOUJNF ར༻͢ΔͨΊ

     w +4ʹɺDMBTT໊ͷલNPEVMF໊௥Ճඞཁ w ݁࿦ɿ࢖͑·͕͢ɺ໘౗ɻ΍Ίͯͷํ͕͍͍