title: How to place a UISwitch in an UITableViewCell accessoryView?
body: <p>I would like to place an <code>UISwitch</code> in a <code>accessoryView</code> of a <code>UITableViewCell</code>, the problem is that if I try to place it right in the <code>cellForRowAtIndexPath</code> func it works and the UISwitch is correctly created and displayed at the right of the UITableViewCell, instead if I create it outside of the func it won't work. I need to create it outsite of the fun because I need to check the status of the UISwitch in some other func and execute code accordingly.</p>
  
  <p>I explain better what I mean for "<em>outside</em>": with <code>Objective-C</code> you have <code>@property(ies)</code> that lets you access objects from everywhere inside the current class file, can we achieve the same thing in <code>Swift</code>?</p>
  
  <p>This is my code:</p>
  
  <pre><code>import UIKit
  
  class ConfigurationViewController: UITableViewController, UITextFieldDelegate {
      weak var useAuthenticationSwitch: UISwitch!
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
  
          if indexPath.section == 0 {
              if indexPath.row == 0 {
                  cell.textLabel!.text = "Use Authentication"
                  cell.accessoryView = useAuthenticationSwitch
              }
          } else {
  
          }
  
          return cell
      }
  }
  </code></pre>
  
  <p>If, instead of:</p>
  
  <pre><code>cell.accessoryView = useAuthenticationSwitch
  </code></pre>
  
  <p>I use:</p>
  
  <pre><code>cell.accessoryView = UISwitch()
  </code></pre>
  
  <p>It works</p>