Skip to content

Instantly share code, notes, and snippets.

@wotjd
Created December 17, 2018 07:36
Show Gist options
  • Save wotjd/5ffada89de9fb3fc6a29a25cde47f327 to your computer and use it in GitHub Desktop.
Save wotjd/5ffada89de9fb3fc6a29a25cde47f327 to your computer and use it in GitHub Desktop.
Compare Version
extension String {
func isNewer(than compareVersion: String) -> Bool {
if self.compare(compareVersion, options: NSString.CompareOptions.numeric) == ComparisonResult.orderedDescending {
return true
}
return false
}
}
"0.9.0".isNewer(than: "0.9") // true
let currentVersion = "0.9.0"
let targetVersion = "0.9.5"
if !currentVersion.isNewer(than: targetVersion) {
// update
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment