Random int in Cocoa on the iPhone
Friday, May 1st, 2009So you just need a random int value in Objective-C? Here you go. The following code produces a random int between 0 and 4:
srandom(time(NULL));
int i = random()%4;
Please note, this is NOT a very efficient way to get randoms. Use it only to get a relativly random number every now and then
