热更新和热修复 个人小结

热修复和热更新

1 热更新和热修复:在线修复程序的 BUG

2 JSPach 的使用原理: OC 是一门动态运行时的语言,方法的运行和对象的创建是在运行时中创建的.JSPatch 正的用运行时,通过JavaScriptCore.framework作为 JS引擎,从 JS 动态调用方法和对象到OC 中,再作用NSInvocation动态调用对应的方法.例

    Class class = NSClassFromString(@"UIViewController");

    id controller = [class new];

    SEL selector = NSSelectorFromString(@"viewDidLoad");

    [controller performSelector:selector];

3 使用步骤

            把JSPatch这个文件夹拖入到文件中然后将在 gitHub 下载的dome.js文件拖入到项目中,在 APPDelegate中:

#import "AppDelegate.h"

#import "JPEngine.h"

#import "ViewController.h"

 

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(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

 

并在 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 {

 

}

最后将 dome.js 中的 JSViewController 改为 ViewController 即可

 

React Native

扫盲:是一种可以同时操作前段,后台,移动端都能实时更新开发的技术

注:通过 JavaSript运行时来创建JavaSript的代码

具体运用这篇文章写的很好  链接: https://zhuanlan.zhihu.com/p/19996445

转载于:https://www.cnblogs.com/xuan-yuan/p/5602318.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值