Tutorial by Examples

The arc4random_uniform() function is the simplest way to get high-quality random integers. As per the manual: arc4random_uniform(upper_bound) will return a uniformly distributed random number less than upper_bound. arc4random_uniform() is recommended over constructions like ''arc4random() % uppe...
The following code demonstrates usage of arc4random_uniform() to generate a random integer between 3 and 12: uint32_t randomIntegerWithinRange = arc4random_uniform(10) + 3; // A random integer between 3 and 12 This works to create a range because arc4random_uniform(10) returns an integer between...

Page 1 of 1