JSPatch ios
ios开发不能不知的动态修复bug补丁第三方库JSPatch 使用学习:JSPatch导入、和使用、.js文件传输加解密git
ios开发面临审核周期长,修复bug延迟等让人无奈的问题,因此,热修复的产生成为必然。github
ios上线APP产生bug,须要及时修复,如何修复:jsp
我整理了jspatch的使用说明,并创建一个简单demo供他人使用和学习,此博客不作详细介绍,具体如何使用附上代码地址:学习
代码下载地址: https://github.com/niexiaobo/JSPatchUseui
##### demo.js里添加代码:一、重写crashBtnClick方法 二、跳转新建的JPTableViewController控制器spa
//一、修改ViewController控制器的handleBtn方法(原控制器漏此方法,会致使崩溃)。 defineClass('ViewController', {//defineClass:声明要被修改的控制器 crashBtnClick: function(sender) { //声明要被修改或重写的方法 var tableViewCtrl = JPTableViewController.alloc().init() self.navigationController().pushViewController_animated(tableViewCtrl, YES) }, }) //二、新建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()) } }) ##### 更新频率