开始 1.0

Start 1.0

Igor Matyushkin维护。




Start 1.0

Start

概览

Start 是一个处理应用启动时发生的不同事件的工具。

如何开始

  • 复制Source文件夹的内容到您的项目中。

或者

  • 使用Start cocoa pod

要求

  • iOS 9 或更高版本
  • Xcode 9 或更高版本
  • Swift 4

用法

启动次数

在您的AppDelegate中,增加由Start库存储的启动次数

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // ...
    
    Start.launches.increment()
    
    // ...
    
    return true
}

现在您可以检索应用的启动次数

let launchCount = Start.launches.count

检查应用是否首次启动非常简单

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // ...
    
    Start.launches.increment()
    
    // ...
    
    switch Start.launches.count {
    case 1:
        // The first launch
        break
    default:
        // Not the first launch
        break
    }
    
    // ...
    
    return true
}

有时可能需要重置启动次数

Start.launches.reset()

许可证

Start 遵循 Apache 2.0 许可协议。更多信息请参阅 LICENSE 文件。