Created
February 2, 2016 02:04
-
-
Save yarshure/1e5c1b032da8a37485d5 to your computer and use it in GitHub Desktop.
Swift version String compare
This file contains hidden or 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
| let target = "1.1.7" | |
| let romver = "1.1.23" | |
| if romver.compare(target, options: NSStringCompareOptions.NumericSearch, range: nil, locale: nil) == NSComparisonResult.OrderedDescending { | |
| print("abc") | |
| }else { | |
| print("def") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One weird case.
"1.0.0".compare("1.0", options: .numeric, range: nil, locale: nil)gives you.orderedDescendinglol.