title: Filtering Tuple in Swift
body: <p>I have simple code: </p>
  
  <pre><code>var recipes = ["Shrimp with garlic", "Napoleon cake", "Beef steak"]
  var searchResults = String[]()
  
  func filterContentForSearchText (searchText: String) {
      searchResults = recipes.filter{ ($0 as NSString).localizedCaseInsensitiveContainsString("\(searchText)") }
  }
  
  func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchString searchString: String!) -&gt; Bool {
      self.filterContentForSearchText (searchString)
      return true
  }
  
  func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -&gt; Int {
      if tableView == self.searchDisplayController.searchResultsTableView {
          return searchResults.count
      } else {
          return recipesDict.count
      }
  }
  
  func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell! {
      var cell = tableView.dequeueReusableCellWithIdentifier("SimpleTableCell") as? UITableViewCell
  
      if !cell {
          cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "SimpleTableCell")
      }
  
      if tableView == self.searchDisplayController.searchResultsTableView {
          cell!.textLabel.text = searchResults[indexPath.row]
          cell!.image = UIImage(named: "food.jpg")
      } else {
          cell!.textLabel.text = recipes[indexPath.row]
          cell!.image = UIImage(named: "food.jpg")
      }
      return cell
  }
  </code></pre>
  
  <p>It was work good. Table is full, table search works. Now I want to complicate the task:</p>
  
  <pre><code>var recipesDict = [(id: 1, name: "Shrimp with garlic", desc: "Lorem Ipsum....", time: 15, img: "shrimp.jpg"), 
  (id: 2, name: "Napoleon cake", desc: "Lorem Ipsum....", time: 120, img: "napoleon.jpg"), 
  (id: 3, name: "Beef steak", desc: "Lorem Ipsum....", time: 15, img: "steak.jpg")]
  </code></pre>
  
  <p>Change table functions:</p>
  
  <pre><code>func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -&gt; Int {
      if tableView == self.searchDisplayController.searchResultsTableView {
          return searchResults.count
      } else {
          // return recipes.count
          return recipesDict.count
      }
  }
  
  func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell! {
      var cell = tableView.dequeueReusableCellWithIdentifier("SimpleTableCell") as? UITableViewCell
  
      if !cell {
          cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "SimpleTableCell")
      }
  
      if tableView == self.searchDisplayController.searchResultsTableView {
          cell!.textLabel.text = searchResults[indexPath.row]
          cell!.image = UIImage(named: "food.jpg")
      } else {
          var currentRecipe = recipesDict[indexPath.row]
          NSLog ("Текущий рецепт : \(currentRecipe)")
          cell!.textLabel.text = currentRecipe.name
          cell!.image = UIImage(named: currentRecipe.img)
          // cell!.textLabel.text = recipes[indexPath.row]
          // cell!.image = UIImage(named: "food.jpg")
      }
      return cell
  }
  </code></pre>
  
  <p>The table is still filled in correctly. Each row have your own image.I can't make filter for array of tuples. Can you suggest how I must modify the function filterContentForSearchText?</p>
  
  <p>Thanks!</p>