对日常最常用到的随机数封装了两个限制随机数生成范围的 C 函数。
1 2 3 4 5 6 7 8 9 10 11
|
NSInteger RandomValue(int fromValue, int toValue) { NSInteger randomValue = arc4random() % (toValue - fromValue + 1) + fromValue; return randomValue; } NSInteger RandomToValue(int toValue) { NSInteger randomValue = arc4random() % (toValue + 1); return randomValue; }
|
近期评论