title: How do I segue from a programmatically created UITableView?
body: <p>I'm working on an app that has a menu that slides in from the left. The menu built programatically using a <a href="https://gist.github.com/codebeaulieu/036fff790d50ab6e5b5b" rel="nofollow">UITableView</a> and an <a href="https://gist.github.com/codebeaulieu/c741e6be1e6b80e2d94e" rel="nofollow">NSObject</a>. I've been able to populate the slide out menu with items but I don't know how to create a segue with an Identifier without using Interface Builder.</p>
  
  <p>Here's what I am tying to do in my tableView:</p>
  
  <pre><code>override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      let cellForRow = tableView.cellForRowAtIndexPath(indexPath)
      let cellLabel = cellForRow?.textLabel?.text
  
      delegate?.sideBarControlDidSelectRow(indexPath, cellName: cellLabel!)  
  
      if (cellLabel == "Item1") {
          self.performSegueWithIdentifier("item1Settings", sender: nil)
      } else {
          self.performSegueWithIdentifier("item2Settings", sender: nil)
      }
  
  }
  </code></pre>
  
  <p><em>( gist: <a href="https://gist.github.com/codebeaulieu/036fff790d50ab6e5b5b" rel="nofollow">SideBarTableViewController</a>)</em></p>
  
  <p>When I click a cell in the menu I get the following error:</p>
  
  <blockquote>
    <p>2015-06-11 18:35:28.720 SideBarApp[2862:1111870] <strong>* Terminating app
    due to uncaught exception 'NSInvalidArgumentException', reason:
    'Receiver () has no
    segue with identifier 'item1Settings''
    *</strong> First throw call stack: (0x1822882d8 0x193aac0e4 0x186fe4c00 0x10000b030 0x10000b108 0x186df1474 0x186eab790 0x186d4c240
    0x186cbc6ec 0x1822402a4 0x18223d230 0x18223d610 0x1821692d4
    0x18b97f6fc 0x186d2efac 0x1000147cc 0x19412aa08) libc++abi.dylib:
    terminating with uncaught exception of type NSException</p>
  </blockquote>
  
  <p>After searching stack I found a few solutions in Objective-C but nothing for Swift with this scenario. </p>
  
  <p><strong>How do I segue from a programmatically created UITableView?</strong></p>
  
  <hr>
  
  <p>This is where I assemble the UITableView programmatically:</p>
  
  <p><strong>SideBar.swift</strong> <a href="https://gist.github.com/codebeaulieu/c741e6be1e6b80e2d94e" rel="nofollow">View Entire File</a></p>
  
  <pre><code>func setupSideBar(){
  
      sideBarContainerView.frame = CGRectMake(-barWidth - 1, originView.frame.origin.y, barWidth, originView.frame.size.height)
      sideBarContainerView.backgroundColor = UIColor.clearColor()
      sideBarContainerView.clipsToBounds = false
  
      originView.addSubview(sideBarContainerView)
  
      let blurView:UIVisualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light))
      blurView.frame = sideBarContainerView.bounds
      sideBarContainerView.addSubview(blurView)
  
  
      sideBarTableViewController.delegate = self
      sideBarTableViewController.tableView.frame = sideBarContainerView.bounds
      sideBarTableViewController.tableView.clipsToBounds = false
      sideBarTableViewController.tableView.separatorStyle = UITableViewCellSeparatorStyle.None
      sideBarTableViewController.tableView.backgroundColor = UIColor.clearColor()
      sideBarTableViewController.tableView.scrollsToTop  = false
      sideBarTableViewController.tableView.contentInset = UIEdgeInsetsMake(sideBarTableViewTopInset, 0, 0, 0)
  
      sideBarTableViewController.tableView.reloadData()
     sideBarContainerView.addSubview(sideBarTableViewController.tableView)
  
      }
  </code></pre>
  
  <p>Here is where I call it:</p>
  
  <p><strong>ViewController.swift</strong> (initial view)</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      imageView.image = UIImage(named: "image2")
      sideBar = SideBar(sourceView: self.view, menuItems: ["first item", "second item", "funny item", "another item"])
      sideBar.delegate = self
  
      }
  </code></pre>