歡迎加入QQ討論群258996829

Swift 寫的版本比較工具 Versions

發(fā)布時(shí)間:2016-09-03 20:50  回復(fù):0  查看:4615  感興趣:28  贊:0   最后回復(fù):2016-09-03 20:50  

Swift 寫的版本比較工具 Versions,可以使用字符串的方式比較版本號(hào)。

示例代碼:

Comparing with the current applications version couldn't be easier.

// App.version is 1.0.0
if App.version.olderThan("2.0.0") {
  // Prompt user to update
}
But you can apply this to more things than just the CFBundleShortVersionString .

let currentVersion = "1.0.1a"
if currentVersion.olderThan("1.1.3") {
    // update
}
Versions also support semantic versioning (Major Minor Patch )

if "1.0".semanticCompare("2.0") == Semantic.Major) {
    // major update
}

相關(guān)開源代碼

您還未登錄,請(qǐng)先登錄

熱門帖子

最新帖子

?