Question: I have created a storyboard with 12 buttons, 12 smaller buttons and 12 labels. 

It is like that:

```
btnBig1.tag = 1
btnSmall1.tag = 1
lbl1.tag = 1

btnBig2.tag = 2
btnSmall2.tag = 2
lbl2.tag = 2

```

etc...

Now when a procedure is called

```
- (IBAction)processButtonUpInside:(id)sender
{
     UIButton *nButton = (UIButton*)sender;
     int nInt =  nButton.tag;
}

```

... I would like to do something with all 3 controls (big button, small button and label).

It should look like this (pseudo-code):

```
- (IBAction)processButtonUpInside:(id)sender
{
     UIButton *nButton = (UIButton*)sender;
     int nInt =  nButton.tag;

     UIButton *nButtonBig (UIButton*)CastFromTagID(nInt)
     //do something with the big button

     UIButton *nButtonSmall (UIButton*)CastFromTagID(nInt)
     //do something with the small button

     UILabel *nLabel (UILabel*)CastFromTagID(nInt)
     //do something with the label

}

```

As you can see, the `CastFromTagID` is my "own invention". I don't know how I should actually do this. 

Can somebody help?
Thank you very much.

Answer: 
You shouldn't assign the same tag id to different views.

Indeed, do something like this:

```
btnBig1.tag = 11 btnSmall1.tag = 12 lbl1.tag = 13;
btnBig2.tag = 21 btnSmall2.tag = 22 lbl2.tag = 23;

```

Then consider the last digit of the tag id:

```
UIView *nView = (UIView *)sender;
if (lastDigit(sender.tag) == 3)
// this is a label 
{
    UIButton *nButtonBig = [nView.superview viewWithTag:nInt-2];
    UIButton *nButtonSmall = [nView.superview viewWithTag:nInt-1];
    UILabel *nLabel = (UILabel *)sender;
}
else if (lastDigit(sender.tag) == 2)
.....

```

where *lastDigit(sender.tag)* is a function that returns the last digit of a given integer.
In my case where I don't have a reference to the subviews that I want to edit under the same tag I just grab all of the subviews for a given view then loop through all of them and check the tag, if the tag match I execute some code. For example..

```
#define kSameViewTag 9500001

for (int i = 0; i < 10; i++) // add a bunch of same tag views // 
{
  UIView *someview = [UIView new];
  someview.tag = kSameViewTag;
  [YourParent addSubview:someview];
}

```

Then later on or whenever you need to loop through your views you can do.

```
NSArray *subviews = [[YourParent subviews] copy];
for (UIView *v in subviews)
{
  if (v.tag == kSameViewTag)
  {
    // Do some code //
  }
}

```

Now this may become an performance issue if you have a lot of subviews so you can always run it on the background thread then jump into the main thread to do UI updates. For Example: 

```
NSArray *subviews = [[YourParent subviews] copy];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
    for (UIView *v in subviews)
    {
        if (v.tag == kSameViewTag)
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                // Do Some UI Stuff Here //
            });
        }
    }
});

```