What is Referencing outlet collection in Xcode4 Interface Builder?

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

Leave a Comment

tech