Random Number in Cocoa and Objective-c
Generating a random number is fairly simple using arc4random(). Say you want a random integer between 10 (min) and 1000 (max). Here's how to do it:
Also, no need to do any seeding with this method.
int max = 1000; int min = 10; int value = (arc4random() % max) + min;
Also, no need to do any seeding with this method.
Labels: arc4random, random number
1 Comments:
Thanks! Does it repeat same number again?
By Anonymous, At September 8, 2011 at 2:17 PM
Post a Comment
Subscribe to Post Comments [Atom]
<< Home