zoukankan      html  css  js  c++  java
  • 热更新和热修复 个人小结

    热修复和热更新

    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

  • 相关阅读:
    MacOs 与 Windows 用U盘交换文件
    Tutorial install and use AppImage on Ubuntu 20.10
    How to set FullScreen Mode on MacOS
    Github Fork 之后与源仓库保持同步
    Mac键盘实现Home, End, Page UP, Page DOWN这几个键
    在 Laravel 的数据库模型中使用状态模式
    利用 Linux col 命令过滤手册文档中的控制符
    深入理解 __init__.py 文件在 python3 和 python2 下的不同
    python配置文件INI/TOML/YAML/ENV的区别
    IPython TAB 代码补全问题
  • 原文地址:https://www.cnblogs.com/xuan-yuan/p/5602318.html
Copyright © 2011-2022 走看看