How to add objects to IBOutletCollection?

I declared NSArray in my class

NSArray             *labelsArray;

I made it a property

@property (nonatomic,retain) IBOutletCollection(UILabel) NSArray *labelsArray;

I connected it to four UILabels in IB. I allocated the array. When i do this

NSLog(@"labelsArray.count %i",[labelsArray count]);

It tells me that labelsArray's count is 0. What should i do to actually add those labels to the array?


I allocated the array.

It could be that the array is automatically instantiated for you when the NIB file is loaded and that reallocating it creates a new (empty) version of the array. Try not allocating it. Also make sure you NSLog the array in viewDidLoad, when the IB elements are loaded.

Need Your Help

Advantage of NoSQL on saving text data


Q1. Why do people often prefer to use NoSQL over RDBMS for storing data like tweets?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.