Personal Summary of hot update and Hotfix, and summary of hot update and repair
Hotfix and hotupdate
1. Hot update and Hotfix: Online BUG fixes
2. How JSPach works: OC is a language for dynamic runtime, and method runtime and object creation are created during runtime. JSPatch uses JavaScriptCore. as a JS engine, framework dynamically calls methods and objects from JS to OC, and then uses NSInvocation to dynamically call corresponding methods. example
Class class = NSClassFromString (@ "UIViewController ");
Id controller = [class new];
SEL selector = NSSelectorFromString (@ "viewDidLoad ");
[Controller extends mselector: selector];
3 Procedure
Drag the JSPatch folder to the file and drag the dome. js file downloaded from gitHub to the project. In APPDelegate:
# Import "AppDelegate. h"
# Import "JPEngine. h"
# Import "ViewController. h"
@ Interface AppDelegate ()
@ End
@ Implementation AppDelegate
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
[JPEngine startEngine];
NSString * jsPath = [[NSBundle mainBundle] pathForResource: @ "demo. js" ofType: nil];
[JPEngine evaluateScriptWithPath: jsPath];
Self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen]. bounds];
ViewController * rootViewController = [[ViewController alloc] init];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController: rootViewController];
Self. window. rootViewController = navigationController;
[Self. window makeKeyAndVisible];
Return YES;
}
@ End
And implemented in ViewController. m
-(Void) viewDidLoad {
[Super viewDidLoad];
UIButton * btn = [[UIButton alloc] initWithFrame: CGRectMake (0,100, [UIScreen mainScreen]. bounds. size. width, 50)];
[Btn setTitle: @ "Push JPTableViewController" forState: UIControlStateNormal];
[Btn addTarget: self action: @ selector (handleBtn :) forControlEvents: UIControlEventTouchUpInside];
[Btn setBackgroundColor: [UIColor grayColor];
[Self. view addSubview: btn];
}
-(Void) handleBtn :( UIButton *) btn {
}
Change JSViewController in dome. js to ViewController.
React Native
Literacy
Note
Use this article to write a good link: https://zhuanlan.zhihu.com/p/19996445