Last active
April 30, 2019 11:57
-
-
Save Shinolr/76f9814954e9026ed247e7fef56adbc2 to your computer and use it in GitHub Desktop.
Check app version, whether should load user guide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol AppGuide { | |
func shouldLoadAppGuide() -> Bool | |
} | |
extension AppGuide { | |
func shouldLoadAppGuide() -> Bool { | |
guard let versionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else { | |
return false | |
} | |
guard let currentVersion = Int(versionString) else { | |
return false | |
} | |
let lastVersion = UserDefaults.standard.integer(forKey: "CFBundleVersion") | |
guard currentVersion > lastVersion else { | |
return false | |
} | |
UserDefaults.standard.set(currentVersion, forKey: "CFBundleVersion") | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment