iOS Developer

iOS业务解耦之启动布局AppDelegate拆分

2017-08-25  本文已影响180人  找不到工作的iOS

解决AppDelegate.m内部代码过于臃肿的问题

解决方案

1.创建AppDelegate分类
root.png push3F427D0.png
2.在AppDelegate分类内实现业务逻辑
10001-8C24-30A8415130EE.png
#import "AppDelegate.h"
#import "AppDelegate+RootVIewCtrl.h"
#import "AppDelegate+Push.h"

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    [self configRootView]; //配置window与根控制器相关
    [self configPush]; //配置推送业务相关

    return YES;
}
#import "AppDelegate+RootVIewCtrl.h"

@implementation AppDelegate (RootVIewCtrl)

- (void)configRootView{
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    //self.window.rootViewController = rootVC;
}

@end
#import "AppDelegate+Push.h"

@implementation AppDelegate (Push)

- (void)configPush {
    
    //推送配置
    
}

@end

上一篇 下一篇

猜你喜欢

热点阅读