I have quite a few similar UILabels
I setup in code.
In Objective-C I would do something like this (pseudo-code):
@property (nonatomic, strong) UILabel *l1, *l2, *l3, *l4, *l5, *l6, *l7, *l8, *l9;
...
l1 = [[UILabel alloc] init];
l2 = [[UILabel alloc] init];
l3 = [[UILabel alloc] init];
...
NSArray *lbls = @[l1, l2, l3, l4, l5, l6, l7, l8, l9];
for(UILabel *l in lbls) {
l.textColor = [UIColor redColor];
l.hidden = YES;
...
[self.addSubview:l];
}
How would I do this in Swift? How can I pass the reference to a variable in a for in
loop?
The only option I found was to make a function with an inout
parameter, but that splits my code into different areas.
Thanks