JSPatch下发笔记1

原代码

@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)