I'm asking for help on this. I have no idea why is this happening, but it looks like every instance of UISwitch isn't being deallocated ... ever
Simplest way to experience it:
class Switchy : UISwitch {
deinit {
print("bye, just smile and :wave: boys") // This will never be printed
}
}
....
Switchy(frame: .zero) // never being deallocated
UISwitch(frame: .zero).rx.deallocating.subscribe(onNext: { _ in print("This will never be called") })
UISwitch(frame: .zero).rx.deallocated.subscribe(onNext: { _ in print("This will never be called") })
Basic retain cycle.
UISwitch seems to retain an instance of a UISwitchModernVisualElement object through the _visualElement property, with retain itself the UISwitch element through the _switchControl property.
=> bugreport.apple.com ?


Oh yeah, good catch! It's happening on the beta as well, UISwitch is never deallocated.
As @JegnuX said, it seems an rdar is necessary.
I've just reported it on bugreport.apple.com ¯_(ツ)_/¯
Most helpful comment
Basic retain cycle.
UISwitchseems to retain an instance of aUISwitchModernVisualElementobject through the_visualElementproperty, with retain itself theUISwitchelement through the_switchControlproperty.=> bugreport.apple.com ?