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