vendredi 6 mars 2015

Why does my random number generator always generate the same random numbers?

I am creating a Game that needs to generate a Random Number. It works, but the problem is, it is the same random order of numbers every time! I have looked at other questions on StackOverflow but I am not able to implement the srand(time(NULL)); into my project.


The action to create a random number is in this void statement.



-(void)NewEmoji{
int text = rand() % 189;
switch (text) {
case 0:
Emoji.text = @"😄";
break;
case 1:
Emoji.text = @"😃";
break;
case 2:


ect.... for the next 187 Characters..


So, I need to make the random generator to be a random number everytime!


Thank!





Aucun commentaire:

Enregistrer un commentaire