Here, I have pointed to the Referencing Outlet Collection
. I am not able to figure out its usage in XCode4.
I am asking for the `new feature of REFERENCING OUTLET COLLECTION in InterfaceBuilder of XCode4".
An outlet is a property that is annotated with the symbol IBOutlet and whose value you can set graphically in a nib file or a storyboard. You declare an outlet in the interface of a class, and you make a connection between the outlet and another object in the nib file or storyboard.
As the name says, an IBOutletCollection is a collection of IBOutlets . It can either be a collection of UI elements. An IBOutletCollection of UIButton in code will look like this: @IBOutlet var starButtons: [UIButton]! It will be an array of UIButton objects.
The IBOutletCollection
is a way to group IBOutlets
. Imagine that you have 3 or 4 UILabels
, on which you will apply a style (font, backgroundColour, opacity, etc). With a IBOutletCollection
, it becomes trivial to do this. First you need to define your IBOutletCollection
:
@property (nonatomic, retain) IBOutletCollection(UILabel) NSArray *labelsCollection;
(notice the type we are putting inside parenthesis, although we could put an id
, if we had a mix collection)
Connect the IBoutlets
on Interface Builder and then just iterate it:
for(UILabel *label in labelsCollection) { // Apply your styles }
Hope this helps you understand:
http://useyourloaf.com/blog/2011/3/28/interface-builder-outlet-collections.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With