Using Jspatch can solve such problems, just introduce jspatch in the project, you can find the bug when the JS script patch, replace the native method, no need to update the app to fix the bug immediately.
@implementation jptableviewcontroller...-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: ( Nsindexpath *) indexpath{nsstring *content = Self.datasource[[indexpath Row]]; The array range may be exceeded resulting in crash jpviewcontroller *ctrl = [[Jpviewcontroller alloc] initwithcontent:content]; [Self.navigationcontroller Pushviewcontroller:ctrl];} ... @end
Taking an array element in the code above may cause crash to be outside the array range. If Jspatch is referenced in the project, a JS script can be issued to fix the bug:
#import "JPENGINE.M" @implementation appdelegate- (BOOL) Application: (uiapplication *) Application didfinishlaunchingwithoptions: ( nsdictionary *) launchoptions{ [jpengine startengine]; [nsurlconnection sendasynchronousrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@] Http://cnbang.net/bugfix. JS "]] queue:[nsoperationqueue mainqueue] completionhandler:^ (Nsurlresponse *response, nsdata *data, nserror *connectionerror) { nsstring * script = [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]; if (script) { [jpengine evaluatescript: Script]; }}]; .... return yes;} @end
Jsdefineclass ("Jptableviewcontroller", {//instance method definitions Tableview_didselectrowatindexpath:function (TableView, Indexpath) {var row = Indexpath.row () if (Self.datasource (). length > Row) {//plus the logical VAR of the judgment bounds content = Self.dataar R () [row]; var ctrl = Jpviewcontroller.alloc (). initwithcontent (content); Self.navigationcontroller (). Pushviewcontroller (ctrl); } }}, {})
This jptableviewcontroller in the-tableview:didselectrowatindexpath: replaced by this JS script implementation, the user is not aware of the situation fixed the bug.
Risk:
Jspatch gives the scripting language the ability to invoke all native OC methods, unlike web front-end capabilities that are limited to browsers, with some security risks:
1. If the transmission of the network in the text JS, may be the intermediary to tamper with JS script, execute any method, steal the relevant information in the app. The transfer process can be encrypted or resolved with direct use of HTTPS.
2. If the JS saved on the download is not encrypted locally, the user can also manually replace or tamper with the script on the jailbroken machine. This harm is not the 1th largest, because the operator is the owner of the mobile phone, there is no risk of misappropriation of information in the app. To prevent users from modifying the code to affect the app's operation, you can choose simple encrypted storage.
jspatch– Dynamic Update iOS APP