5

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?

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161

2 Answers2

3

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.

jbat100
  • 16,757
  • 4
  • 45
  • 70
1

Where are you calling the NSLog statement? The array will not be instantiated until viewDidLoad is called.

Rayfleck
  • 12,116
  • 8
  • 48
  • 74