ios开发不能不知的动态修复bug补丁第三方库JSPatch 使用学习:JSPatch导入、和使用、.js文件传输加解密

JSPatch

ios开发不能不知的动态修复bug补丁第三方库JSPatch 使用学习:JSPatch导入、和使用、.js文件传输加解密

ios开发面临审核周期长,修复bug延迟等让人无奈的问题,所以,热修复的产生成为必然。

ios上线APP产生bug,需要及时修复,如何修复:

我整理了jspatch的使用说明,并建立一个简单demo供他人使用和学习,此博客不做详细介绍,具体如何使用附上代码地址:

代码下载地址: https://github.com/niexiaobo/JSPatchUse

 

 

##### demo.js里添加代码:1、重写crashBtnClick方法 2、跳转新建的JPTableViewController控制器

    //1、修改ViewController控制器的handleBtn方法(原控制器漏此方法,会导致崩溃)。

    defineClass('ViewController', {//defineClass:声明要被修改的控制器
    crashBtnClick: function(sender) { //声明要被修改或重写的方法
    var tableViewCtrl = JPTableViewController.alloc().init()
    self.navigationController().pushViewController_animated(tableViewCtrl, YES)
    },

    })

    //2、新建JPTableViewController控制器

    defineClass('JPTableViewController : UITableViewController <UIAlertViewDelegate>', ['data'], {
    dataSource: function() {
    var data = self.data();
    if (data) return data;
    var data = [];
    for (var i = 0; i < 20; i ++) {
    data.push("通过js创建的cell " + i);
    }
    self.setData(data)
    return data;
    },
    numberOfSectionsInTableView: function(tableView) {
    return 1;
    },
    tableView_numberOfRowsInSection: function(tableView, section) {
    return self.dataSource().length;
    },
    tableView_cellForRowAtIndexPath: function(tableView, indexPath) {
    var cell = tableView.dequeueReusableCellWithIdentifier("cell") 
    if (!cell) {
    cell = require('UITableViewCell').alloc().initWithStyle_reuseIdentifier(0, "cell")
    }
    cell.textLabel().setText(self.dataSource()[indexPath.row()])
    return cell
    },
    tableView_heightForRowAtIndexPath: function(tableView, indexPath) {
    return 60
    },
    tableView_didSelectRowAtIndexPath: function(tableView, indexPath) {
    var alertView = require('UIAlertView').alloc().initWithTitle_message_delegate_cancelButtonTitle_otherButtonTitles("Alert",self.dataSource()[indexPath.row()], self, "OK",  null);
    alertView.show()
    },
    alertView_willDismissWithButtonIndex: function(alertView, idx) {
    console.log('click btn ' + alertView.buttonTitleAtIndex(idx).toJS())
    }
    })


 #####  更新频率
posted @ 2016-09-27 17:11  穿山甲随笔-iOS开发  阅读(318)  评论(0编辑  收藏  举报