Reputation: 17892
Is there anyway to group objects?
Say for example I have UIImageView1, UIImageView2, and UIImageView3 and I want to hide them all... do I have to type EVERY TIME
UIImageView1.hidden = YES;
UIImageView2.hidden = YES;
UIImageView3.hidden = YES;
Or is there anyway that I can define a group and just say group1.hidden = YES;
Upvotes: 0
Views: 59
Reputation: 458
you must add 3 imageView to a parentView and then
foreach (UIView *view in parentView.subViews) {
if([view isMemberOf:[UIImageView class]])
{
[view setHidden:YES];
} }
by other way you can add tag for each imageView above and get it to setHidden
Upvotes: 2
Reputation: 539805
You could use Key-Value Coding:
NSArray *imageViews = @[imageView1, imageView2, imageView3];
[imageViews setValue:@YES forKey:@"hidden"];
This works because calling setValue:forKey:
on an NSArray
invokes setValue:forKey:
on each of the array's items.
Upvotes: 2