<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKRandomSource/sharedRandom()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKRandomSource(cm)sharedRandom"
  },
  "title" : "sharedRandom()"
}
-->

# sharedRandom()

Returns a shared instance that shares a system-wide random source.

```
class func sharedRandom() -> GKRandomSource
```

## Return Value

The shared system random source.

## Discussion

The system random source shares state with the arc4random family of C functions. Generating random numbers with this source modifies the outcome of future calls to those functions, and calling those functions modifies the sequence of random values generated by this source. As such, this source is neither deterministic nor independent—use it only for trivial gameplay mechanics that do not rely on those attributes.

To instead use an independent random source, create an instance of one of the [`GKRandomSource`](/documentation/GameplayKit/GKRandomSource) subclasses. The [`GKARC4RandomSource`](/documentation/GameplayKit/GKARC4RandomSource) class employs a similar algorithm but is independent from the system random source.

---

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)