title: How to filter contents of UITableView that has custom cell with Search Bar in Swift?
body: <p>I am building iOS App using swift and Xcode version 6.3</p>
  
  <p>I have created a tableview,searchbar as an outlet.</p>
  
  <p>After that i created a new class ProjectTableviewCell as subclass of UITableview cell.</p>
  
  <p>In my storyboard i connected multiple labels to prototype cell.</p>
  
  <p>I implemented searchbar methods.And its filtering data in the tableviewcell properly.This all working fine.</p>
  
  <p>In default before i search any content tableview displays list of contents.</p>
  
  <p>After the filtering operation it displays only the particular filtered array only.</p>
  
  <p>The problem now i am facing is in tableview cell contents is not displaying.</p>
  
  <p>My Expected output is i want to show the filtered array with the existing cell contents in my tableview.</p>
  
  <pre><code>class myProjects: UIViewController,UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate {
  
  
  @IBOutlet weak var projectTable: UITableView!
  @IBOutlet weak var searchProject: UISearchBar!
  var project = [String]()
  var searchActive : Bool = false
  
  var filtered:[String] = []
  //Search Bar Methods
  func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
      searchActive = true;
  }
  
  func searchBarTextDidEndEditing(searchBar: UISearchBar) {
      searchActive = false;
  }
  
  func searchBarCancelButtonClicked(searchBar: UISearchBar) {
      searchActive = false;
  }
  
  func searchBarSearchButtonClicked(searchBar: UISearchBar) {
      searchActive = false;
  }
  
  func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
  
      filtered = project.filter({ (text) -&gt; Bool in
          let tmp: NSString = text
          let range = tmp.rangeOfString(searchText, options: NSStringCompareOptions.CaseInsensitiveSearch)
          return range.location != NSNotFound
      })
      if(filtered.count == 0){
          searchActive = false;
      } else {
          searchActive = true;
      }
      self.projectTable.reloadData()
  }
  
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          if(searchActive) {
          return filtered.count
          }
          return project.count;
      }
  
  
  
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      let textCellIdentifier = "Cell"
      let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as! projectTableViewCell
      let row = indexPath.row
  
      if(searchActive){
          cell.textLabel?.text = filtered[indexPath.row]
  
      } else {
      (cell.contentView.viewWithTag(1)  as! UILabel).text = project[row] as String
      }
      (cell.contentView.viewWithTag(3)  as! UILabel).text = projectStatus[row] as String
      (cell.contentView.viewWithTag(7)  as! UILabel).text = ProjectDescription[row] as String
      (cell.contentView.viewWithTag(12) as! UILabel).text = category[row] as String
      (cell.contentView.viewWithTag(13) as! UILabel).text = subcategory[row] as String
      (cell.contentView.viewWithTag(14) as! UILabel).text = project_Tags[row] as String
      (cell.contentView.viewWithTag(15) as! UILabel).text = skill_Needed[row] as String
      (cell.contentView.viewWithTag(16) as! UILabel).text = budget[row] as String
      (cell.contentView.viewWithTag(17) as! UILabel).text = timeFrames[row] as String
      (cell.contentView.viewWithTag(18) as! UILabel).text = location[row] as String
  
      return cell
  }
  </code></pre>
  
  <p>I am Beginner in Swift.Your help will be much appreciated.</p>