JSPatch下发笔记1

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

目录
打赏
0
0
0
0
5
分享
相关文章
|
10月前
|
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
151 0
|
10月前
|
Vue.js组件精讲 组件的通信2:派发与广播——自行实现dispatch和broadcast方法
Vue.js 的 provide/inject API 主要用于跨级组件通信,侧重于子组件获取上级状态。但无法良好处理两种场景:父向子(跨级)传递数据和子向父(跨级)传递数据。在这种情况下,虽然Vue推荐使用Vuex,但在某些场景下,可以使用自定义的`dispatch`和`broadcast`方法。这两个方法在Vue 1.x中存在,但在2.x中被废弃。`$emit`用于触发当前组件的自定义事件,而`$on`用于监听这些事件。在Vue 2.x中,我们将自行实现`dispatch`和`broadcast`以实现类似的功能,允许父子组件(包括跨级)之间的通信,特别是当组件层级不深且无需全面状态管理时
85 0
|
10月前
|
JS逆向 -- HOOK关键数据
JS逆向 -- HOOK关键数据
114 0
JSPatch下发笔记2
JSPatch下发笔记2
154 0
JSPatch下发笔记8
JSPatch下发笔记8
139 0
JSPatch下发笔记7
JSPatch下发笔记7
145 0
JSPatch下发笔记5
JSPatch下发笔记5
129 0
JSPatch下发笔记6
JSPatch下发笔记6
114 0
JSPatch下发笔记9
JSPatch下发笔记9
118 0