0001 #if os(Linux) 0002 import Glibc 0003 #else 0004 import Foundation 0005 #endif 0006 0007 extension Int { 0008 /** 0009 * Generates a random number between (and inclusive of) 0010 * the given minimum and maxiumum. 0011 */ 0012 public static func random(min min: Int, max: Int) -> Int { 0013 let top = max - min + 1 0014 #if os(Linux) 0015 return Int(Glibc.random() % top) + min 0016 #else 0017 return Int(arc4random_uniform(UInt32(top))) + min 0018 #endif 0019 } 0020 }
Session.swift:58 key += "\(Int.random(min: 0, max: 9999))"Session.swift:60 key += "\(Int.random(min: 0, max: 9999))"Session.swift:62 key += "\(Int.random(min: 0, max: 9999))"