App 升级,NSUserDefaults 记录 launch 信息

每个版本的 App 第一次被用户打开时,展示 launch 页面:

let hasLanchedForVersionKey = "HasLaunchedForVersion"
let currentVersion = 3

if NSUserDefaults.standardUserDefaults().integerForKey(hasLanchedForVersionKey) < currentVersion {
    NSUserDefaults.standardUserDefaults().setInteger(currentVersion, forKey: hasLanchedForVersionKey)
    NSUserDefaults.standardUserDefaults().synchronize()
    
    // This is the first lanch for this version
    // ...
} else {
    // App hasn't been updated since last launch
}

参考 NSUserDefaults behaviour with app update

你可能感兴趣的:(App 升级,NSUserDefaults 记录 launch 信息)