I have a very simple iPhone app that requires a random integer from 1-100.
I have a button that calls the random number function then displays it.
-(IBAction)buttonReleased;
{
srandom(time(NULL));
int theNum = random() % 100 + 1;
numberDisplay.text = [NSString stringWithFormat:@"%d", theNum];
}
The problem is, if I press the button quickly, sometimes it won't display a new random number.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…