iOS App版本号compare
生活随笔
收集整理的這篇文章主要介紹了
iOS App版本号compare
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參考原文:https://www.jianshu.com/p/1dd7745f5ee4
NSStringCompareOptions里有個NSNumericSearch
?/* Added in 10.2; Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find */
Object-C
NSString *currentVersion = @"1.2.1";NSString *serverVersion = @"1.11.1";if ([currentVersion compare:serverVersion options:NSNumericSearch] == NSOrderedAscending) {NSLog(@"需要更新");}Swift
let currentVersion = "1.2.1"let serverVersion = "1.11.1"if currentVersion.compare(serverVersion, options: .numeric) == .orderedAscending {print("需要更新")}?
轉載于:https://www.cnblogs.com/liuyongfa/p/9967919.html
總結
以上是生活随笔為你收集整理的iOS App版本号compare的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python技巧 使用值来排序一个字典
- 下一篇: 敏捷冲刺四