OBJECTIVE-C does not directly provide random data generation functions or methods, but we can directly use C's various random algorithms
The following is the use of several common random number algorithms, which can be referenced in the following header file
Stdlib.h
Arc4random
Random seeds are automatically generated at call time without the need for random seed
Returns a collection of [0,x]
int value = Arc4random ()% x;
Returns the collection of [1,x]
int value = (arc4random ()% x) + 1;
Random ()/rand ()
Does not use the seed random number to return any number within the Long/int range
Notice here the random returns long Rand returns int
Srandom (unsigned)/srand (unsigned)
Use random seed to return any number of arguments to Rand_max
Note that the Srandon here can use unsigned long as a parameter
It is to be noted that the RAND series random number uses a pseudo random algorithm, which is recommended to make different random seeds
For example:
Srand (Time (NULL))