0
我想我的IBAction随机选择括号中的一个动作。随机调用不同动作的IBAction?
我该怎么做?
谢谢!
- (IBAction) randomAction{
[self choice1];
[self choice2];
[self choice3];
}
我想我的IBAction随机选择括号中的一个动作。随机调用不同动作的IBAction?
我该怎么做?
谢谢!
- (IBAction) randomAction{
[self choice1];
[self choice2];
[self choice3];
}
试试这个
- (IBAction) randomAction{
switch (arc4random()%3){
case 0:
[self choice1];
break;
case 1:
[self choice2];
break;
case 2:
[self choice3];
break;
default:
break;
}
}
这样的作品,谢谢!我将如何去做循环而不是随机的行为? – dot 2012-02-20 09:33:37
'for(int i = 0; i <3 * 100; ++ i){switch(i%3){....}}' - 它会执行100次 – beryllium 2012-02-20 09:58:04