Skip to content

Instantly share code, notes, and snippets.

@viccc
Created January 3, 2016 16:13
Show Gist options
  • Save viccc/9aced7bfda9b4cbdeb5a to your computer and use it in GitHub Desktop.
Save viccc/9aced7bfda9b4cbdeb5a to your computer and use it in GitHub Desktop.
func randomInt(range: Range<Int>) -> Int {
let base = range.endIndex - range.startIndex
let r = arc4random_uniform(UInt32(base))
let n = Int(r) + range.startIndex
return n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment