Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. static func isOutdated(thisVersion: String, comparisonVersion: String) -> Bool {
  2.  
  3. let thisVersionComponents = thisVersion.components(separatedBy: ".")
  4. let comparisonVersionComponents = comparisonVersion.components(separatedBy: ".")
  5.  
  6. let thisVersionNumbers: [Int] = thisVersionComponents.map { Int($0) ?? 0 }
  7. let comparisonVersionNumbers: [Int] = comparisonVersionComponents.map { Int($0) ?? 0 }
  8.  
  9. for i in 0 ..< 3 {
  10. if thisVersionNumbers[i] > comparisonVersionNumbers[i] {
  11. return false
  12. }
  13. else if thisVersionNumbers[i] < comparisonVersionNumbers[i] {
  14. print("Outdated version")
  15. return true
  16. }
  17. }
  18.  
  19. return false
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement