Created
May 17, 2018 01:05
-
-
Save enomoto/d600b87563d2c1f897959f856b44646c to your computer and use it in GitHub Desktop.
samples of NSComparisonResult
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
import Foundation | |
// https://developer.apple.com/documentation/foundation/nscomparisonresult | |
let currentVersion = "0.0.2" | |
let latestVersion1 = "0.0.3" | |
let latestVersion2 = "0.0.21" | |
let latestVersion3 = "0.1.0" | |
let latestVersion4 = "1.0.0" | |
let latestVersion5 = "0.0.2" | |
// tests | |
(currentVersion.compare(latestVersion1) == .orderedAscending) == true | |
(latestVersion1.compare(myVersion) == .orderedAscending) == false | |
(myVersion.compare(latestVersion2) == .orderedAscending) == true | |
(myVersion.compare(latestVersion3) == .orderedAscending) == true | |
(myVersion.compare(latestVersion4) == .orderedAscending) == true | |
(myVersion.compare(latestVersion5) == .orderedAscending) == false | |
(myVersion.compare(latestVersion5) == .orderedDescending) == false | |
(myVersion.compare(latestVersion5) == .orderedSame) == true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment