// 方法1
int x = arc4random() % 100;
// 方法2
int x = arc4random_uniform(100);
// 方法1
int y = (arc4random() % 501) + 500;
// 方法2
int y = arc4random_uniform(500 + 1) + 500;
// 范围在[from,to]
- (int)getRandomNumber:(int)from to:(int)to
{
return arc4random_uniform(to - from + 1) + from;
// return (arc4random() % (to - from + 1)) + from;
}