<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKRandom",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(pl)GKRandom"
  },
  "title" : "GKRandom"
}
-->

# GKRandom

The common interface for all randomization classes in (or usable with) GameplayKit.

```
protocol GKRandom
```

## Overview> Important:
> The randomization services provided in GameplayKit are suitable for reliably creating deterministic, pseudorandom gameplay mechanics, but are not cryptographically robust. For cryptography, obfuscation, or cipher uses, use the Security framework, described in [Cryptographic Services Guide](https://developer.apple.com/library/archive/documentation/Security/Conceptual/cryptoservices/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011172).

GameplayKit randomization classes include the [`GKRandomSource`](/documentation/GameplayKit/GKRandomSource) and [`GKRandomDistribution`](/documentation/GameplayKit/GKRandomDistribution) classes and their subclasses. You use those classes to generate random behavior for gameplay mechanics, and use this protocol type directly when composing random sources to create more complex randomizers.

For more information on choosing and using randomizers in GameplayKit, read [Randomization](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/RandomSources.html#//apple_ref/doc/uid/TP40015172-CH9) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Generating Random Numbers

[`-  nextInt`](/documentation/GameplayKit/GKRandom/nextInt())

Generates and returns a new random integer.

[`-  nextIntWithUpperBound:`](/documentation/GameplayKit/GKRandom/nextInt(upperBound:))

Generates and returns a new random integer less than the specified limit.

[`-  nextUniform`](/documentation/GameplayKit/GKRandom/nextUniform())

Generates and returns a new random floating-point value.

[`-  nextBool`](/documentation/GameplayKit/GKRandom/nextBool())

Generates and returns a new random Boolean value.

## Relationships

### Conforming Types

[`GKGaussianDistribution`](/documentation/GameplayKit/GKGaussianDistribution)

[`GKRandomDistribution`](/documentation/GameplayKit/GKRandomDistribution)

[`GKMersenneTwisterRandomSource`](/documentation/GameplayKit/GKMersenneTwisterRandomSource)

[`GKARC4RandomSource`](/documentation/GameplayKit/GKARC4RandomSource)

[`GKRandomSource`](/documentation/GameplayKit/GKRandomSource)

[`GKShuffledDistribution`](/documentation/GameplayKit/GKShuffledDistribution)

[`GKLinearCongruentialRandomSource`](/documentation/GameplayKit/GKLinearCongruentialRandomSource)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)