I need a way to get all UILabels within a UIView without having to go through all the views within the UIView.
I have many other type of views, UIButtons, UIImageViews and it would be too long to go through all of them when I just need the UILabels.
I’m trying to avoid something like this:
for (UIView *view in myView.subviews)
{
if([view isKindOfClass:[UILabel class]])
{
UILabel *lbl = (UILabel*)view;
}
}
Is it possible or am I dreaming?
Create an
NSArrayivar which you can add all theUILabel‘s to.If you do it in code then as you create the
UILabeljust doIf you use IB the declare your property like this
and connect all the labels up to this.