Many games have a need to generate random numbers. If you are making an iOS game with SpriteKit, the GameplayKit framework has classes for generating random numbers.
Generating random numbers has two steps.
Create a random number generator Generate a random number Creating a Random Number Generator Create an instance of GKRandomDistribution, which is GameplayKit’s class for generating random numbers. Supply the low and high values to define the range of numbers the generator can generate.