Skip to content

Instantly share code, notes, and snippets.

@jakebromberg
Last active November 25, 2017 22:21
Show Gist options
  • Save jakebromberg/7bbc2e3aac1dac3322ed0c52cd731320 to your computer and use it in GitHub Desktop.
Save jakebromberg/7bbc2e3aac1dac3322ed0c52cd731320 to your computer and use it in GitHub Desktop.
Swifty wrapper around arc4random
import Foundation
public extension Numeric {
static func arc4random() -> Self {
var r: Self = 0
arc4random_buf(&r, Int(MemoryLayout<Self>.size))
return r
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment