iOS Development hot Update Jspatch

Source: Internet
Author: User

Jspatch, you can use JavaScript to invoke any Objective-c native interface to get scripting language capabilities by simply introducing a minimal engine into your project: dynamically update the app and replace the project native code to fix the bug.

Have you ever had this experience: the new version on the line found that there is a serious bug, may lead to crash rate surge, may make the network request can not be issued, at this time can do is to quickly fix the bug and then submit to wait for a lengthy appstore audit, and then look forward to users to upgrade quickly, pay huge human and time costs To complete the fix for this bug.

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{  *content = Self.datasource[[indexpath row]];  // may exceed array range 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:

 // js  defineclass ( " jptableviewcontroller  "   { // instance method definitions   Tableview_didselectrowatindexpath:function (TableView, Indexpath) {var row = Indexpath.row ()  if  ( Self.datasource (). length > Row) {//       Add the logical  var content = Self.dataarr () [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.

Principle

Jspatch uses iOS built-in javascriptcore.framework as the JS engine, but does not use its Jsexport features for Js-oc function intermodulation, but through the objective-c Runtime, Transfer the class name function name from JS to Objective-c, and then use Nsinvocation to invoke the corresponding OC method dynamically.

Jspatch is more in line with Apple's rules. IOS Developer Program License Agreement 3.3.2 mentions that executable code cannot be issued dynamically, except for code executed by Apple Javascriptcore.framework or WebKit, JS is executed by Javascriptcore.framework.

Dynamic Update scenario comparison: Jspatch vs React Native

iOS Development hot Update Jspatch

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.