I am creating a small game with an interface that is quite similar to 4 Pictures 1 word. The current setup so far is as follows: 
The user gets a 7 letter word generated at random. 
There is an array which takes the 7 letters and then randomly populates them with other letters in 12 programatically created UIButtons:

```
for (int i=0; i< buttonCount; i++) {
    int xpositiong = x + 37;
    x = xpositiong;

    isSeven ++;
    restAt7 ++;

    NSString *stringFromInt = [NSString stringWithFormat:@"%@",[arrayForRound objectAtIndex:i]];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

    [button addTarget:self
               action:@selector(buttonSelected:)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:stringFromInt forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont fontWithName:@"helvetica" size:19];
    button.tag = i+10;
    _letterButton = button; 

    if (restAt7 == 7) {
        x = 47;
    }

    if (isSeven <= 6) {

        button.frame = CGRectMake(x,333,40,40);
    }
    else
    {
        button.frame = CGRectMake(x,370,40,40);

    }

    [self.view addSubview:button];
}

```

There is also a second area of Buttons however these are static and constitute as "the word". When one of the 12 letters are selected it takes the tag of the selected button and populates one of the corresponding "word" buttons. 

```
-(void)buttonSelected : (UIButton *)sender
{
 NSLog(@"sender %i", sender.tag);
 UIButton *button = (UIButton *)[self.view viewWithTag:sender.tag];
 button.hidden = YES;

if ([_buttonOne.titleLabel.text isEqualToString: @" "]) {
    // NSLog(@"button is nil");
    [_buttonOne setTitle:sender.titleLabel.text forState:UIControlStateNormal];
    [_buttonOne setTag:button.tag];
}
else if ([_buttonTwo.titleLabel.text isEqualToString:@" "])
{
    [_buttonTwo setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}
else if ([_buttonThree.titleLabel.text isEqualToString:@" "])
{
    [_buttonThree setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}
else if ([_buttonFour.titleLabel.text isEqualToString:@" "])
{
    [_buttonFour setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}

else if ([_buttonFive.titleLabel.text isEqualToString:@" "])
{
    [_buttonFive setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}
else if ([_buttonSix.titleLabel.text isEqualToString:@" "])
{
    [_buttonSix setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}
else if ([_buttonSeven.titleLabel.text isEqualToString:@" "])
{
    [_buttonSeven setTitle:sender.titleLabel.text forState:UIControlStateNormal];
}   

```

}

![Before Selection](https://i.stack.imgur.com/Z2t11.png)

![After Selection](https://i.stack.imgur.com/Q1lVl.png)

Right! So here is my question. If the user decides they have selected the wrong letter and wish to remove that letter they can press one of the 7 buttons to delete that letter. However I dont know how to un-hide the corresponding button which was originally populated with the letter... 

I am confident it has something to do with retaining the Tag of the selected button however because each of the 7 buttons is assigned with Tag's I am not sure how to go about doing it.

EDIT:

I'll post up the solution that has worked. Also all functions have been rewritten with loops. 

```
-(void)buttonSelected : (UIButton *)sender
{
 NSLog(@"sender %i", sender.tag);
 UIButton *button = (UIButton *)[self.view viewWithTag:sender.tag];
 button.hidden = YES;

for (int i = 0; i < _wordButtonsArray.count; i ++) {

    UIButton *selectedButton = [_wordButtonsArray objectAtIndex:i];

    if ([selectedButton.titleLabel.text isEqualToString:@" "]) {

        [selectedButton setTitle:sender.titleLabel.text forState:UIControlStateNormal];
        [selectedButton setTag:button.tag];
        return;
    }
}
   [self checkIfAnswerIsFinished:sender];

}

- (IBAction)clearButton:(id)sender
{
UIButton *button = (UIButton *)[self.view viewWithTag:[sender tag]];
button.hidden = NO;

for (int i = 0; i < _wordButtonsArray.count; i ++) {

    if (button == [_wordButtonsArray objectAtIndex:i]) {

        [button setTitle:@" " forState:UIControlStateNormal];

        for (int letterButtonsIndex = 0; letterButtonsIndex < _letterButtonsArray.count; letterButtonsIndex++) {

            UIButton *letterButton = [_letterButtonsArray objectAtIndex:letterButtonsIndex];

            if (button.tag == letterButton.tag) {
                button.tag = i;
            letterButton.hidden = NO;
        }
    }
}
}
}

```

Works like a charm!