Skip to content

Instantly share code, notes, and snippets.

@soggybag
Created January 18, 2016 18:02
Show Gist options
  • Save soggybag/e7e073fcf43dbcd92519 to your computer and use it in GitHub Desktop.
Save soggybag/e7e073fcf43dbcd92519 to your computer and use it in GitHub Desktop.
Random Int Extension using Gameplaykit
import GameplayKit
// MARK:
extension Int {
// Make this a static function for Int
static func randomRange(range: Int) -> Int {
return GKRandomSource.sharedRandom().nextIntWithUpperBound(range)
}
}
// Usage
var dieRoll = Int.randomRange(6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment