I am writing an iOS app and I have one question to make the reading easier.
For example, I have many things to hide so I do this like this :
mytext1.hidden=YES;
mytext2.hidden=YES;
mytext3.hidden=YES;
…
Is there any way to write this :
(mytext1, mytext2, mytext3).hidden =YES;
?
Thanks
You can iterate an array with a selector like this:
…and there’s a variation that takes a single object parameter. This won’t handle scalar types, though, so to set hidden=YES, you can enumerate using a block:
If that’s too verbose for your taste, you can add methods to the array class that assume, say, a collection of controls. These would just conceal the enumeration, but the caller could be as simple as this:
Easy on the eyes, right? You can achieve this by creating your own custom category of NSArray methods: