Swift 2016-09-03 20:50
Swift 写的版本比较工具 Versions
回复:0 查看:5137 感兴趣:28 赞:0
Swift 写的版本比较工具 Versions,可以使用字符串的方式比较版本号。
示例代码:
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
}
相关开源代码
EFIconFont: 一个用 Swift 实现的 IconFont 封装
Swift Zip文件压缩与解压框架
EFResume - 一个普通的 Swift 简历模板
Swift 优雅的定时器及执行工具库 Each
Swift 解析、格式化及验证国际电话号码工具库 PhoneNumberKit
Swift 版 FlatBuffers(跨平台序列化库)FlatBuffersSwift
Swift 编写的 Github API 客户端 Github.swift
Swift OAuth授权库 SwiftyOAuth
Swift 音频处理库 TempiFFT
iOS通知中心封装库SwiftNotificationCenter