jspatch– Dynamic Update iOS APP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.