Searching TableView can't select row

While searching a tableView, every time I try to select a row it just takes me back to the unsearched tableView. What am I missing? the segue works perfectly when not filtering through the table. The ability to select a row just disapears while the searchBar is activated.

import UIKit import Foundation  class BenchmarkWODViewController: UITableViewController, UISearchResultsUpdating {      var WodList = [WOD]()     var FilteredWodList = [WOD]()     var Keyword = ""     var searchController : UISearchController?     var index = Int()      @IBAction func backButton(sender: AnyObject) {         self.navigationController?.popViewControllerAnimated(true)     }      override func viewDidLoad() {         super.viewDidLoad()          for wodData in BenchmarkWODs.library {             let wod = WOD(dictionary: wodData)             WodList.append(wod)     }      // Search Bar         self.searchController = UISearchController(searchResultsController: nil)         self.searchController?.searchBar.autocapitalizationType = .None         self.tableView.tableHeaderView = self.searchController?.searchBar         self.searchController?.searchResultsUpdater = self         self.Keyword = ""         definesPresentationContext = true          self.filterByName()     }       func filterByName(){         self.FilteredWodList = self.WodList.filter({ (wod: WOD) -> Bool in             if self.Keyword.characters.count == 0 {             return true         }          if (wod.name?.lowercaseString.rangeOfString(self.Keyword.lowercaseString)) != nil {             return true         }         return false     })         self.tableView.reloadData()     }       // Search Bar Function     func updateSearchResultsForSearchController(searchController:     UISearchController) {         Keyword = searchController.searchBar.text!         self.filterByName()     }        override func numberOfSectionsInTableView(tableView: UITableView) -> Int {         return 1     }      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {         return self.FilteredWodList.count     }      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell     {         let cell = tableView.dequeueReusableCellWithIdentifier("BenchmarkCell", forIndexPath: indexPath) as UITableViewCell         let wod = self.FilteredWodList[indexPath.row]          if let wodName = wod.name {         cell.textLabel?.text = wodName     }         return cell     }        override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {      self.filterByName()         self.performSegueWithIdentifier("showBenchmarkDetail", sender: nil)     }  } 

Replay

Category: ios Time: 2016-07-29 Views: 6

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.207 (s). 12 q(s)