Search code examples
iosobjective-ciboutletcollection

IBOutletCollection not connected with UILabels in Storyboard


I have an IBoutletCollection property connected to several UILabels in Storyboard:

@property (weak, nonatomic) IBOutletCollection(UILabel) NSArray *labels;

called

NSLog(@"%ld",(long)self.labels.count) after viewDidLoad

got 0 as result.

what's the problem I got empty ivar here?

anything wrong with the Autolayout? (Yes I'm using it in Storyboard)

Thanks for any advice!


Solution

  • Change weak to strong

    @property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *labels;