title: Swift - Function as Variable with Self Reference
body: <p>I've made a struct to hold data for my <code>UITableViewCell</code>s  that looks like so:</p>
  
  <pre><code>struct CellData {
      var title: String
      var action: () -&gt; Void
      init(title: String, action: () -&gt; Void) {
          self.title = title
          self.action = action
      }
  }
  </code></pre>
  
  <p>And in my <code>TableViewController</code>, I'm setting it up like this:</p>
  
  <pre><code>lazy var buttonCells: [CellData] = [
      CellData(
          title: "Button 1",
          action: {
              **self.doSomething()**
          }
      ),
      CellData(
          title: "Button 2",
          action: {
              **self.doSomethingElse()**
          }
      )
  ]
  </code></pre>
  
  <p>However, the use of <code>self</code> inside the action causes it so that the <code>TableViewController</code> isn't <code>deinitialized</code> when the controller is dismissed (the <code>deinit</code> function isn't called). When I remove the <code>self</code> references, and replace it with something else, the <code>TableViewController</code> is <code>deinitialized</code> just fine. How can I go about fixing this abandoned memory issue? </p>