在2个定义的int之间随机选择

| 在objective-c中有没有一种方法可以让您伪随机地确定两个整数之间的距离?还是有一种快速的方法来实现这一目标?     
已邀请:
使用以下内容:
int number = arc4random() % 2;
if(number==0){
  //pick one number
}else{
  //pick other number
}
    
randomSelection = arc4random() % 2 ? choice1 : choice2;
    
在C ++中将是
result = rand() < 0.5 ? int1 : int2
为什么不能在ObjC中建立相同的命令?     

要回复问题请先登录注册