How do I generate random numbers on iOS?
There is a very similar question here on StackOverFlow. Here is one of the better solutions (no need for seeding):
int r = arc4random() % 5;
i use
#define RANDOM_SEED() srandom(time(NULL))#define RANDOM_INT(__MIN__, __MAX__) ((__MIN__) + random() % ((__MAX__+1) - (__MIN__)))
so you can give a min and max
You should seed the random number generator with the current time.
srand(time(0));