zoukankan      html  css  js  c++  java
  • iOS 小技巧总结

    1.获取准确的app启动所需时间

    应用启动时间长短对用户第一次体验至关重要,同时系统对应用的启动、恢复等状态的运行时间也有严格要求,在应用超时的情况下系统会直接关闭应用。
    以下是几个常见场景下系统对App运行时间的要求:

    Launch 20秒
    Resume 10秒
    Suspend 10秒
    Quit 6秒
    Background Task 10分钟

    1)在点main.m文件中加入

    CFAbsoluteTime StartTime;//开始时间
    int main(int argc, char * argv[]) {
        @autoreleasepool {
             StartTime=CFAbsoluteTimeGetCurrent();//开始时间
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
    }
    

    2)AppDelegate.m文件中加入

    @interface AppDelegate ()
    
    /**
     *  声明startTime,用以在本类中调用main.m中的startTime全局变量。
     */
    extern CFAbsoluteTime StartTime;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.window.backgroundColor = [UIColor whiteColor];
    
        [self.window makeKeyAndVisible];
        
         NSLog(@"程序启动耗时%f秒!",CFAbsoluteTimeGetCurrent()-StartTime);//时间差
    
        return YES;
    }
    
     
     
     
  • 相关阅读:
    esper(4-5)- Context 条件
    esper(4-4)-OverLapping Context
    esper(4-3)-Non-Overlapping Context
    esper(4-2)-Category Context
    esper(4-1)-简单context
    esper(3)-窗口&聚合分组
    esper(2)-事件类型
    java常用代码
    idea(3)-jetty配置
    BP(反向传播)算法原理及推导
  • 原文地址:https://www.cnblogs.com/sixindev/p/4466482.html
Copyright © 2011-2022 走看看