[Fix] It looks like Apple fixed memory leak for UIButton with iOS 10.2. #842

This commit is contained in:
Krunoslav Zaher 2016-12-17 10:32:56 +01:00
parent 582807e83b
commit 9d7ab84920
3 changed files with 6 additions and 11 deletions

View File

@ -15,12 +15,12 @@ import RxSwift
extension Reactive where Base: UISwitch {
/**
Reactive wrapper for `on` property.
**Unlike other controls, Apple is reusing instances of UISwitch or a there is a leak,
so underlying observable sequence won't complete when nothing holds a strong reference
** Versions prior to iOS 10.2 were leaking `UIButton`s, so on those versions
underlying observable sequence won't complete when nothing holds a strong reference
to UISwitch.**
*/
public var value: ControlProperty<Bool> {

View File

@ -127,7 +127,7 @@ extension FlowTests {
_testBarButtonItemTap,
_testButtonTap,
_testSegmentedControl,
//_testUISwitch,
_testUISwitch,
_testUITextField,
_testUITextView,
_testSlider

View File

@ -83,13 +83,9 @@ class APIWrappersViewController: ViewController {
// MARK: UISwitch
/*
// also test two way binding
let switchValue = Variable(true)
/***Unlike other controls, Apple is reusing instances of UISwitch or a there is a leak,
so underlying observable sequence won't complete when nothing holds a strong reference
to UISwitch.***/
(switcher.rx.value <-> switchValue).addDisposableTo(disposeBag)
_ = switcher.rx.value <-> switchValue
switchValue.asObservable()
.subscribe(onNext: { [weak self] x in
@ -100,9 +96,8 @@ class APIWrappersViewController: ViewController {
// MARK: UIActivityIndicatorView
switcher.rx.value
.bindTo(activityIndicator.rx.animating)
.bindTo(activityIndicator.rx.isAnimating)
.addDisposableTo(disposeBag)
*/
// MARK: UIButton