美文网首页
JSPatch下发笔记1

JSPatch下发笔记1

作者: anny_4243 | 来源:发表于2016-12-20 18:30 被阅读19次

原代码

@implementation CommunityViewController
- (void)jump:(UIButton *)sender{
    CommunityBannerModel *model = _arr[sender.tag];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:model.action_type forKey:@"type"];
    [dict setValue:model.url forKey:@"value"];
    [[PushJumpManager sharedInstance]pushActionWithModel:dict];
}
@end

JS代码

require('NSMutableDictionary,PushJumpManager');
defineClass('CommunityViewController', {
            jump: function(sender) {
            var i = sender.tag();
            var model = self.valueForKey("_arr").objectAtIndex(i);
            console.log(model);
            var dict = NSMutableDictionary.dictionary();
            console.log(dict);
            dict.setValue_forKey(model.valueForKey("action_type"), "type");
            console.log(model.valueForKey("action_type"));
            dict.setValue_forKey(model.valueForKey("url"), "value");
            console.log(model.valueForKey("action_type"));
            console.log(dict);
            PushJumpManager.sharedInstance().pushActionWithModel(dict);
            },
            });

注意:
1.把需要用到的类写在require方法里,相当于引用。
2.实例变量的写法。
_arr 写成 self.valueForKey("_arr")
3.数组下标的写法。
arr[i]写成arr.objectAtIndex(i)
4.jsonModel值的写法。
model.url写成model.valueForKey("url")
5.在调试的时候把需要打印的值用console.log()方法输出到控制台方便调试。

相关文章

  • JSPatch下发笔记1

    原代码 JS代码 注意:1.把需要用到的类写在require方法里,相当于引用。2.实例变量的写法。_arr ...

  • JSPatch下发笔记10

    OC代码: JS代码: 总结:NSForegroundColorAttributeName 在js中要写成"NSC...

  • JSPatch下发笔记2

    原代码 JS代码 注意:1.block中的self要在block外面声明成:_ _weak typeof(self...

  • JSPatch下发笔记8

    OC代码: JS代码: 总结:1.注意for in循环和for循环的区别,for in循环是一次性取出所有的元素进...

  • JSPatch下发笔记7

    oc代码: JS代码: 总结: 当在for循环中用到block的时候,在JS中,block里取到的永远是i的最大值...

  • JSPatch下发笔记9

    OC代码: JS代码: 注:OC中的字符串@"document.getElementsByTagName('met...

  • JSPatch下发笔记5

    JS代码: 总结:1.Masonry中遇到单下划线要改成双下划线 ,数值@2,要改成22.变量名中遇到单下划线要改...

  • JSPatch下发笔记4

    OC代码: JS代码: 总结:1.修改多个类中的代码,用defineClass("");分隔。2.遇到枚举值用原值代替

  • JSPatch下发笔记6

    OC代码: JS代码: 总结:1.不可变数组表示方法,OC:@[image],JS:[image]。2.字典取值方...

  • JSPatch下发笔记3

    OC代码: JS代码: 总结:1.扩展类的写法:如:NSString (Float) 写成defineClass(...

网友评论

      本文标题:JSPatch下发笔记1

      本文链接:https://www.haomeiwen.com/subject/xolfvttx.html