rex_text extensions seems to leave behind persistent objects
avalanched opened this issue · comments
Setup: I have a UICollectionView with 4 UICollectionViewCell's that contain a UILabel
class SectionBarCollectionViewCell: UICollectionViewCell, ReactiveView {
static let DefaultIdentifier = "identifier"
var viewModel = MutableProperty<SectionBarCellViewModel?>(nil)
let titleLabel = Label()
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
func commonInit() {
contentView.addSubview(titleLabel)
bindObservers()
}
func bindObservers() {
titleLabel.rex_text <~ viewModel.producer |> flatMap(.Latest) { $0?.title.producer ?? SignalProducer(value: "") } |> ignoreNil
}
func bindViewModel(viewModel: AnyObject) {
if let viewModel = viewModel as? SectionBarCellViewModel {
self.viewModel.put(viewModel)
}
}
}
when I profile my application it seems that the UILabel won't get destroyed when the UICollectionViewCell's are deinit
if i do it without binding, it destroys the UILabel as suspected when the Cell is deinit.
viewModel.producer |> flatMap(.Latest) { $0?.title.producer ?? SignalProducer(value: "") } |> start(next: {[unowned self] title in self.titleLabel.text = title })
Took a quick look at the code and think I found the retain cycle. I'll have to spend some time testing it out and looking for a fix