SHARE
TWEET

Untitled

a guest Mar 24th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top