I would like to know how to make it so that the same picture is not chosen twice in a row. Lets say pictures are given a number 1-3. If picture 1 is chosen, then picture 1 will not be chosen next. If picture 3 is chosen, then picture 1 can be chosen again, and so on.
I know that I would have to use a while statement, except I don't know how. Heres what I have as of now:
- (void)chooseBackgroundImage{
  if(thisNumber % 10 == 0){
    int chooseBackgroundImage = arc4random() % 7;
    switch (chooseBackgroundImage) {
        case 0:
            backgroundImage.image = [UIImage imageNamed:@"CyanToYellowBackground.png"];
            break;
        case 1:
            backgroundImage.image = [UIImage imageNamed:@"GreenToBlueBackground.png"];
            break;
        case 2:
            backgroundImage.image = [UIImage imageNamed:@"OrangeToGreenBackground.png"];
            break;
        case 3:
            backgroundImage.image = [UIImage imageNamed:@"OrangeToPurpleBackground.png"];
            break;
        case 4:
            backgroundImage.image = [UIImage imageNamed:@"PurpleToCyanBackground.png"];
            break;
        case 5:
            backgroundImage.image = [UIImage imageNamed:@"RedToBlueBackground.png"];
            break;
        case 6:
            backgroundImage.image = [UIImage imageNamed:@"YellowToRedBackground.png"];
            break;
       }
    }
}
I've also tried using:
- (void)chooseBackgroundImage{
if(slogansGenerated % 10 == 0){
    int chooseBackgroundImage = arc4random() % 7;
    while(chooseBackgroundImage == oldChooseBackgroundImage){
    switch (chooseBackgroundImage) {
        case 0:
            backgroundImage.image = [UIImage imageNamed:@"CyanToYellowBackground.png"];
            break;
        case 1:
            backgroundImage.image = [UIImage imageNamed:@"GreenToBlueBackground.png"];
            break;
        case 2:
            backgroundImage.image = [UIImage imageNamed:@"OrangeToGreenBackground.png"];
            break;
        case 3:
            backgroundImage.image = [UIImage imageNamed:@"OrangeToPurpleBackground.png"];
            break;
        case 4:
            backgroundImage.image = [UIImage imageNamed:@"PurpleToCyanBackground.png"];
            break;
        case 5:
            backgroundImage.image = [UIImage imageNamed:@"RedToBlueBackground.png"];
            break;
        case 6:
            backgroundImage.image = [UIImage imageNamed:@"YellowToRedBackground.png"];
            break;
    }
    int oldChooseBackgroundImage = chooseBackroundImage
  }
}
But nothing seems to work. Is there any way to create a non-repeating random number?
 
     
     
    