---
title: "nextInt(upperBound:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkrandomdistribution/nextint(upperbound:)"
---

# nextInt(upperBound:)

Generates and returns a new random integer within the bounds of the distribution and less than the specified limit.

## Declaration

```swift
func nextInt(upperBound: Int) -> Int
```

## Parameters

- `upperBound`: A limit on the values of random numbers to generate.

## Return Value

Return Value A new random integer less than the value of the upperBound parameter.

## Discussion

Discussion Randomly generated integers are in the range specified by the distribution’s lowestValue and highestValue properties (inclusive). The actual upper bound on numbers generated by this method is the lesser of the highestValue property and the upperBound parameter. When using the GKRandomDistribution directly, generated numbers are uniform within this range. Subclasses of GKRandomDistribution can alter the relative probability of generating any particular number within the distribution’s range.

## See Also

### Generating Random Numbers

- [nextInt()](gameplaykit/gkrandomdistribution/nextint().md)
- [nextUniform()](gameplaykit/gkrandomdistribution/nextuniform().md)
- [nextBool()](gameplaykit/gkrandomdistribution/nextbool().md)
