Swift 2 :IBOutlet Collection [UIButton]! leaks mem

2019-04-21 03:29发布

问题:

Recently in my app I have found out that my UIButton outlet collection is leaking memory.

All I have is

    @IBOutlet var TabBarButtons: [UIButton]!

And from Instrument

Can anyone tell me what's gone wrong? As time goes on, the amount of variables in the NSArray keeps growing and all I have is an array with 4 UIButtons from IB.

回答1:

This is a bug. Reference rdar://24272775

Workaround for now is to replace [UIButton]! with NSArray! and cast its contents to UIButton later when used.