Instance Method

shuffledArrayWithRandomSource:

Returns a new array that lists this array’s elements in a random order, using the specified random source.

Declaration

- (NSArray<ObjectType> *)shuffledArrayWithRandomSource:(GKRandomSource *)randomSource;

Parameters

randomSource

A GameplayKit random source object.

Return Value

A new array that lists this array’s elements in a random order.

Discussion

Use the randomSource parameter to influence the random shuffling. For example, to reproduce a series of shuffles for testing, you can create a GKARC4RandomSource object using the seed value of a previously used random source.

This method is equivalent to the GKRandomSource method arrayByShufflingObjectsInArray:, but as an NSArray method it preserves generic type parameters.

See Also

Randomly Shuffling an Array

- shuffledArray

Returns a new array that lists this array’s elements in a random order.