title: UISwitch deinit never called
body: <p>A few days ago I've posted a problem <a href="https://stackoverflow.com/questions/39796709/uiswitch-not-deallocating">here</a> and I still havent found an answer for it. I think it's a bug and hope it'll be fixed in the future but can't help but think it might also be something I'm doing wrong myself.</p>
  
  <p>With this question I hope to be able to confirm it's a bug so I can keep continue working on my project without worrying too much about it. If this question is repetitive, I will delete the question right away.</p>
  
  <p>I have subclassed a <code>UISwitch</code> adding a <code>deinit</code> so I can see when it's getting deallocated.</p>
  
  <pre><code>class CustomSwitch: UISwitch { deinit {print("Switch has been deinitialized")} }
  </code></pre>
  
  <p>Then I've added a property in my view controller:</p>
  
  <pre><code>var customSwitch: CustomSwitch? = CustomSwitch()
  </code></pre>
  
  <p>To test it, I've added a button with the following function:</p>
  
  <pre><code>func removeSwitch() {
      print(customSwitch)
      customSwitch = nil
      print(customSwitch)
  }
  </code></pre>
  
  <p>And the following prints out in the console:</p>
  
  <pre><code>Optional(&lt;Debugging.CustomSwitch: 0x7f9ec91083c0; baseClass = UISwitch; frame = (0 0; 51 31); layer = &lt;CALayer: 0x6100000384a0&gt;&gt;)
  nil
  </code></pre>
  
  <p>The deinit message is not printed and in instruments it shows the customSwitch is still in memory.</p>
  
  <p>The only thing I could find about this is <a href="https://github.com/ReactiveX/RxSwift/issues/842" rel="nofollow noreferrer">this</a></p>