Die Zufallszahlenfunktion schlägt fehl
Ich habe eine sehr einfache iPhone-App, die eine zufällige Ganzzahl von 1-100 erfordert.
Ich habe eine Schaltfläche, die die Zufallszahlenfunktion aufruft und dann anzeigt.
-(IBAction)buttonReleased;
{
srandom(time(NULL));
int theNum = random() % 100 + 1;
numberDisplay.text = [NSString stringWithFormat:@"%d", theNum];
}
Das Problem ist, wenn ich die Taste schnell drücke, wird manchmal keine neue Zufallszahl angezeigt.