title: Segueing to another view from a custom cell button in SWIFT for ios app
body: <p>I am coding an ios app in swift.
  I have a ViewController holding a custom table view, which holds a custom cell. Each cell has a switch, upon which activating, I would like the view to segue to a second viewcontroller.</p>
  
  <p>I am attempting to achieve this by declaring a storyboard variable, and instatiating the second view controller, and pushing to the second view controller. I’ve searched the boards for solutions, however none of them seem to work.</p>
  
  <p>Within class customCellTableViewCell: UITableViewCell</p>
  
  <p>Try 1:</p>
  
  <pre><code>customCellTableViewCell: UITableViewCell {
  
  var storyboard:UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
  let view2: viewController2 = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("View2") as viewController2
  switchActive fnc(){
  
  self.window?.rootViewController?.navigationController?.pushViewController(view2, animated: true)
  
  }
  
  …
  //rest of code
  </code></pre>
  
  <p>Error: customCellTableViewCell.Type does not have member named storyboard</p>
  
  <p>Try 2:</p>
  
  <pre><code>customCellTableViewCell: UITableViewCell {
  
  init(storyboard: UIStoryboard){
          self.storyboard = storyboard
  }
  
  required init(coder aDecoder: NSCoder) {
          fatalError("init(coder:) has not been implemented")
  }
  
  var storyboard:UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
  let view2: viewController2 = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("View2") as viewController2
  switchActive fnc(){
  
  self.window?.rootViewController?.navigationController?.pushViewController(view2, animated: true)
  
  }
  
  …
  //rest of code
  </code></pre>
  
  <p>Error: customCellTableViewCell.Type does not have member named storyboard</p>
  
  <p>Try 3:</p>
  
  <pre><code>customCellTableViewCell: UITableViewCell {
  
  
  var storyboard:UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
  let view2: viewController2 = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("View2") as viewController2
  
  switchActive fnc(){
  
  self.window?.rootViewController?.navigationController?.pushViewController(view2, animated: true)
  
  }
  
  …
  //rest of code
  </code></pre>
  
  <p>Put code inside of switchActive fnc, but does not work.
  Replaced var with let, to no avail.
  Tried suggestion in this post, using the lazy attribute
  <a href="https://stackoverflow.com/questions/24724235/how-to-get-global-pointer-to-view-controller-in-swift">How to get global pointer to view controller in swift</a></p>
  
  <p>I cannot figure out what I’m doing wrong. I’ve been stuck for a bit.</p>