What is Referencing outlet collection in Xcode4 Interface Builder?

Sagar Kothari picture Sagar Kothari · Jul 11, 2011 · Viewed 16.3k times · Source

enter image description here

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".

Answer

Rui Peres picture Rui Peres · Jul 11, 2011

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