Posts Tagged ‘objective c’
-(int)getRandomNumber:(int)from to:(int)to {
return (int)from + arc4random() % (to-from+1);
}
How to use:
1) Implement method above into your .m file
2) Add the following line to your .h file:
-(int)getRandomNumber:(int)from to:(int)to;
3) Call the method like:
int randomNumber = [self getRandomNumber:9 to:99]; //this gets you a random number between 9 and 99
