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()方法输出到控制台方便调试。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,253评论 4 61
  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,788评论 0 9
  • 好意思么,大家都蹭鹿晗! ……其中蹭得最贴身、最无耻的,当数咱家成大业。 说真的,无聊不? 有空蹭鹿晗,还不如老实...
    Sir电影阅读 2,131评论 11 24
  • 梦 陨落了 一地的碎片 星 稀疏了 风 轻轻的浮起 拉下帷幕的夜 月 与你共眠
    一亩花塘阅读 139评论 0 1
  • 亚洲宠物展3
    罢不尔奔阅读 96评论 0 0