熱更新和熱修複 個人小結,熱更新修複小結

來源:互聯網
上載者:User

熱更新和熱修複 個人小結,熱更新修複小結

熱修複和熱更新

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.