Skip to content

Instantly share code, notes, and snippets.

@eiffelqiu
Created May 25, 2011 00:49
Show Gist options
  • Save eiffelqiu/990090 to your computer and use it in GitHub Desktop.
Save eiffelqiu/990090 to your computer and use it in GitHub Desktop.
Get random number in a range
-(int)getRandomNumber:(int)from to:(int)to {
return (int)from + arc4random() % (to-from+1);
}
int randomNumber = [self getRandomNumber:9 to:99];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment