デッキからカードを選択できるシンプルなアプリを作成しようとしています。私がする必要があるのは、同じカードを繰り返さないことです. 私はインターネット全体を見てきましたが、これを行う方法があまり明確ではありません。
これが私が今持っているコードです:
-(IBAction) randomize: (id)sender {
int randomcards = rand() % 53 + 1;
switch (randomcards) {
case 0:
imageview.image = [UIImage imageNamed:@"1.png"];
break;
case 1:
imageview.image = [UIImage imageNamed:@"2.png"];
break;
case 2:
imageview.image = [UIImage imageNamed:@"3.png"];
break;
case 3:
imageview.image = [UIImage imageNamed:@"4.png"];
break;
case 4:
imageview.image = [UIImage imageNamed:@"5.png"];
break;
case 5:
imageview.image = [UIImage imageNamed:@"6.png"];
break;
case 6:
imageview.image = [UIImage imageNamed:@"7.png"];
break;
case 7:
imageview.image = [UIImage imageNamed:@"8.png"];
break;
case 8:
imageview.image = [UIImage imageNamed:@"9.png"];
break;
case 9:
imageview.image = [UIImage imageNamed:@"10.png"];
break;
case 10:
imageview.image = [UIImage imageNamed:@"11.png"];
break;
case 11:
imageview.image = [UIImage imageNamed:@"12.png"];
break;
case 12:
imageview.image = [UIImage imageNamed:@"13.png"];
break;
case 13:
imageview.image = [UIImage imageNamed:@"14.png"];
break;
case 14:
imageview.image = [UIImage imageNamed:@"15.png"];
break;
case 15:
imageview.image = [UIImage imageNamed:@"16.png"];
break;
case 16:
imageview.image = [UIImage imageNamed:@"17.png"];
break;
case 17:
imageview.image = [UIImage imageNamed:@"18.png"];
break;
case 18:
imageview.image = [UIImage imageNamed:@"19.png"];
break;
case 19:
imageview.image = [UIImage imageNamed:@"20.png"];
break;
case 20:
imageview.image = [UIImage imageNamed:@"21.png"];
break;
case 21:
imageview.image = [UIImage imageNamed:@"22.png"];
break;
case 22:
imageview.image = [UIImage imageNamed:@"23.png"];
break;
case 23:
imageview.image = [UIImage imageNamed:@"24.png"];
break;
case 24:
imageview.image = [UIImage imageNamed:@"25.png"];
break;
case 25:
imageview.image = [UIImage imageNamed:@"26.png"];
break;
case 26:
imageview.image = [UIImage imageNamed:@"27.png"];
break;
case 27:
imageview.image = [UIImage imageNamed:@"28.png"];
break;
case 28:
imageview.image = [UIImage imageNamed:@"29.png"];
break;
case 29:
imageview.image = [UIImage imageNamed:@"30.png"];
break;
case 30:
imageview.image = [UIImage imageNamed:@"31.png"];
break;
case 31:
imageview.image = [UIImage imageNamed:@"32.png"];
break;
case 32:
imageview.image = [UIImage imageNamed:@"33.png"];
break;
case 33:
imageview.image = [UIImage imageNamed:@"34.png"];
break;
case 34:
imageview.image = [UIImage imageNamed:@"35.png"];
break;
case 35:
imageview.image = [UIImage imageNamed:@"36.png"];
break;
case 36:
imageview.image = [UIImage imageNamed:@"37.png"];
break;
case 37:
imageview.image = [UIImage imageNamed:@"38.png"];
break;
case 38:
imageview.image = [UIImage imageNamed:@"39.png"];
break;
case 39:
imageview.image = [UIImage imageNamed:@"40.png"];
break;
case 40:
imageview.image = [UIImage imageNamed:@"41.png"];
break;
case 41:
imageview.image = [UIImage imageNamed:@"42.png"];
break;
case 42:
imageview.image = [UIImage imageNamed:@"43.png"];
break;
case 43:
imageview.image = [UIImage imageNamed:@"44.png"];
break;
case 44:
imageview.image = [UIImage imageNamed:@"45.png"];
break;
case 45:
imageview.image = [UIImage imageNamed:@"46.png"];
break;
case 46:
imageview.image = [UIImage imageNamed:@"47.png"];
break;
case 47:
imageview.image = [UIImage imageNamed:@"48.png"];
break;
case 48:
imageview.image = [UIImage imageNamed:@"49.png"];
break;
case 49:
imageview.image = [UIImage imageNamed:@"50.png"];
break;
case 50:
imageview.image = [UIImage imageNamed:@"51.png"];
break;
case 51:
imageview.image = [UIImage imageNamed:@"52.png"];
break;
case 52:
imageview.image = [UIImage imageNamed:@"53.png"];
break;
case 53:
imageview.image = [UIImage imageNamed:@"54.png"];
break;
}
デッキが尽きる前に同じカードが 2 回出現するのを防ぐ方法について、明確な指示を誰か教えてくれませんか? よろしくお願いします。