Created
January 18, 2016 18:02
-
-
Save soggybag/e7e073fcf43dbcd92519 to your computer and use it in GitHub Desktop.
Random Int Extension using Gameplaykit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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