How to hide a bunch of shortcuts in IBOutletCollection?

New in the development of Objective-C and iOS, I would like it here!

I wrote some code such that

IBOutletCollection(UILabel) NSArray *allLabels; 

In IB, I linked all my shortcuts in my view to this collection, where I want to hide them for a specific condition. However, I do not know how to do this. Obviously, to hide one label that I would use

 labelX.hidden = YES; 

however for me it is not ideal for this without a collection, since I have many shortcuts to hide.

Thanks for your advice in advance!

+6
source share
3 answers

try it...

 [allLabels setValue:[NSNumber numberWithBool:YES] forKey:@"hidden"]; 
+8
source

Just list the collection and do whatever you want with the contents:

 [allLabels enumerateIndexesUsingBlock:^(UILabel *label, NSUInteger idx, BOOL *stop) { label.hidden = YES; }]; 
+2
source

Fast version for array type:

 (allLabels as NSArray).setValue(NSNumber(bool: true), forKey: "hidden") 
0
source

Source: https://habr.com/ru/post/916822/


All Articles