i have about 100 cells in my app. each _cell is an imageView.
i have an int value named baseValue[x][y], that is randomly generated for each imageView. the cells are named like theyres x&y value, for example: baseValue[5][3] is for _cell53.
is there an other solution than mine?
for(int startingSquares = 0; startingSquares < REVEALED_CELLS; startingSquares++) {
int x = arc4random_uniform(10);
int y = arc4random_uniform(10);
if(newValue[x][y] == 0) {
newValue[x][y] = baseValue[x][y];
if (x == 0 && y == 0) {
[_cell00 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[0][0]]];
}
if (x == 1 && y == 0) {
[_cell10 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[1][0]]];
}
if (x == 2 && y == 0) {
[_cell20 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[2][0]]];
}
if (x == 3 && y == 0) {
[_cell30 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[3][0]]];
}
if (x == 4 && y == 0) {
[_cell40 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[4][0]]];
}
if (x == 5 && y == 0) {
[_cell50 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[5][0]]];
}
.
.
.
if (x == 8 && y == 3) {
[_cell83 setImageNamed:[NSString stringWithFormat:@"Dot_%d.png", baseValue[8][3]]];
}
and so on...
is it realizable in a for loop for all cells?
Aucun commentaire:
Enregistrer un commentaire