首页 > 编程知识 正文

怎么做知识框架笔记,高三古代框架笔记

时间:2023-05-05 15:17:28 阅读:181461 作者:3053

1. mPaaS iOS框架介绍mPaaS iOS框架源于支付宝(Alipay )客户端的开发框架,基于框架的设计思想:

1 .业务请参阅独立的模块

2 .着力追求模块与模块之间的高凝聚、低耦合。

mPaaS iOS框架直接继承APP应用程序的生命周期。

1 .整个APP应用程序开始托管,

2 .应用生命周期管理、处理和分发

3 .统一管理ui APP代理事件、各业务模块(微APP应用和服务)等。

apache Cordova 类似,它应该封装在标准的iOS 层次结构

2 .引导主机通过替换程序主函数直接继承APP应用的生命周期。 整个启动过程如下。

打开主- dfclientdelegate-launcher APP应用程序(MPLauncherAppDelegate ) :

(个人为DF的含义是default,MP是mPaaS的缩写)

2.1查看main函数//main.m//MP H5 demo _ plugin//createdbyvivi.ywon 2019/03/28.//copyright 2019 Alibaba.aliba ifdefhotpatchexistapsecbufferrefapsecgetpks ({ char SIG [ ]={0x 89,0x 55,0x EC,0x 73,0x D3,0x B1,0x 98,0x 98,0xd9)0xb 8,0x 26,0x D5,0x be,0x D2,0x 42,0x de,0x F8,000 x 38,0x7c,0x 27,0x3b,0x 98,0x4b,0x 12,0x 30,0x2f,0x 20x9e、0x9e、0x24、0x5f、0x 61、0xf、0x 3、0xe、0x1e、0x9e、0x1e、0x4c、0x8a、0xba、0x1e、0x 41、0x 41、0x 440x E10x D5,0x E8,0x ca,0x 86,0x4d,004d0x6b,0x 88,0x 22,0x 2,0x B3,0x c8,0x 77,0x24,0xc,0x 62,0xd,0xdf,0xfc0x b5,0x D4,0x D7,0x1d,0x7b,0x 72,0x B2,0x7e,0xb 0,0x 84,0x 9,0x 93,0030x 45,0x B4,0x 18,0x 40,0x DC,0x7b0xFe,0000x 69,0x 78,0x BD,0x9d,0xcf,0xe 5,0x 12,0x df,0xbe,0x 86,0x 86,0x 11,0x 99,0x 36,0x B9,0x B2,0x ee apsecbufferrefbuf=(apsecbufferref ) malloc ) sizeof(apsecbuffer ) len ); buf-length=len; memcpy(buf-data,sig,len ); 返回缓冲区; }#endifintmain(intargc,char * argv[] ) { @autoreleasepool {

#ifdef HOTPATCHEXIST NSString *path; APSecBufferRef buf; int ret; path = [[NSBundle mainBundle] pathForResource:@"pubkey" ofType:@"pem"]; APSecInitPublicKey([path UTF8String]); // 读取并初始化公钥 buf = APSecGetPKS(); // 读取公钥的签名 ret = APSecVerifyFile([path UTF8String], buf->data, buf->length); // 验证公钥文件自身是否符合签名 free(buf); if (ret != 0) { NSLog(@"The public key is modified."); }#endif return UIApplicationMain(argc, argv, @"DFApplication", @"DFClientDelegate"); // NOW USE MPAAS FRAMEWORK }} 2.2查看DFClientDelegate的源码

我们在项目中找不到DFClientDelegate的源码,我们看一下启动时的调用关系栈:

2.3 打开 Launcher 应用

我们来看一下Launcher 应用的一些情况,包括目录结构,头文件,源文件:

 我们发现了,MPLauncherAppDelegate的源文件,头文件,还有个MobileRuntime.plist文件,这个文件的作用之后再说;

我们来看一下头文件的内容:

//// MPLauncherAppDelegate.h#import <Foundation/Foundation.h>@interface MPLauncherAppDelegate : NSObject <DTMicroApplicationDelegate>- (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application;@end

 我们看到了类 MPLauncherAppDelegate,继承自NSObject,遵循协议 DTMicroApplicationDelegate

但是 这个协议是个啥玩意呢?我们看到了在框架里的头文件,我们来仔细看看!

我们看到了协议,返回了应用的根视图控制器,而且这个协议DTMicroApplicationDelegate必须实现;

我们来看一下实现情况(部分代码如下)

@interface MPLauncherAppDelegate ()@property (nonatomic, strong) UITabBarController* tabBarController;@property (nonatomic, strong) UIViewController *rootController;@end- (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application{ return self.rootController;}

我们看到了两个视图的控制器:tabBarController和rootController

看来这是一个 带有tabBar的东西;

我们看一下,这个类的init方法:

- (id)init{ self = [super init]; if (self) { // 这里指定Tab使用的图片 NSArray *baseImgs = [NSArray arrayWithObjects: @"TabBar_HomeBar", @"TabBar_Discovery", @"TabBar_PublicService", @"TabBar_Friends", nil]; NSArray *selectImgs = [NSArray arrayWithObjects: @"TabBar_HomeBar_Sel", @"TabBar_Discovery_Sel", @"TabBar_PublicService_Sel", @"TabBar_Friends_Sel", nil]; UIViewController* tab1ViewController = (UIViewController *) [self createLoggingViewController:@"DemoViewController"]; UIViewController* tab2ViewController = [[DTViewController alloc] init]; UIViewController* tab3ViewController = [[DTViewController alloc] init]; UIViewController* tab4ViewController = [[DTViewController alloc] init]; NSArray *navArray = @[tab1ViewController, tab2ViewController, tab3ViewController, tab4ViewController]; NSArray *titles = @[@"Tab1", @"Tab2", @"Tab3", @"Tab4"]; for (int i = 0; i < [navArray count]; i ++) { UIImage *bImg = [UIImage imageNamed:baseImgs[i]]; UIImage *selectImg = [UIImage imageNamed:selectImgs[i]]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:titles[i] image:bImg selectedImage:selectImg]; item.selectedImage = [item.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item.image = [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item.tag = i; [(UIViewController *)navArray[i] setTabBarItem:item]; ((UIViewController *)navArray[i]).title = titles[i]; } self.tabBarController = [[MPTabBarController alloc] init]; self.tabBarController.viewControllers = navArray; self.tabBarController.selectedIndex = 0; [self.tabBarController.delegate tabBarController:self.tabBarController didSelectViewController:tab1ViewController]; self.rootController = self.tabBarController; } return self;}

它初始化了一些 UIViewController,然后将其与tabBarController连接起来,又将self.tabBarController赋值给self.rootController;

这样,应用程序的委托对象是MPLauncherAppDelegate;

应用的视图是MPLauncherAppDelegate的属性;

参考文档:https://tech.antfin.com/products/MPAAS

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。