博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
热更新和热修复 个人小结
阅读量:4326 次
发布时间:2019-06-06

本文共 1901 字,大约阅读时间需要 6 分钟。

热修复和热更新

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

你可能感兴趣的文章
Android 关于悬浮窗权限的问题
查看>>
如何使用mysql
查看>>
linux下wc命令详解
查看>>
敏捷开发中软件测试团队的职责和产出是什么?
查看>>
在mvc3中使用ffmpeg对上传视频进行截图和转换格式
查看>>
python的字符串内建函数
查看>>
Spring - DI
查看>>
微软自己的官网介绍 SSL 参数相关
查看>>
Composite UI Application Block (CAB) 概念和术语
查看>>
ajax跨域,携带cookie
查看>>
阶段3 2.Spring_01.Spring框架简介_03.spring概述
查看>>
阶段3 2.Spring_02.程序间耦合_1 编写jdbc的工程代码用于分析程序的耦合
查看>>
阶段3 2.Spring_01.Spring框架简介_04.spring发展历程
查看>>
阶段3 2.Spring_02.程序间耦合_3 程序的耦合和解耦的思路分析1
查看>>
阶段3 2.Spring_02.程序间耦合_5 编写工厂类和配置文件
查看>>
阶段3 2.Spring_01.Spring框架简介_05.spring的优势
查看>>
阶段3 2.Spring_02.程序间耦合_7 分析工厂模式中的问题并改造
查看>>
阶段3 2.Spring_02.程序间耦合_4 曾经代码中的问题分析
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_2 spring中的Ioc前期准备
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_4 ApplicationContext的三个实现类
查看>>