title: Swift - Search data not loading
body: <p>I'm trying to add a search feature to my app with Parse, I have wrote the code with a <code>UISearchController</code>, but for some reason when I load the app and try to search nothing works. My parse is all set up correctly, so there must be something wrong with my code!</p>
  
  <p>Here it is:</p>
  
  <pre><code>import UIKit
  import Parse
  class SearchTableViewController: UITableViewController, UISearchResultsUpdating
  {
  
      var searchResults = [String]()
  
      var resultSearchController = UISearchController()
  
      override func viewDidLoad()
      {super.viewDidLoad()
          self.resultSearchController = UISearchController(searchResultsController: nil)
          self.resultSearchController.searchResultsUpdater = self
          self.resultSearchController.dimsBackgroundDuringPresentation = false
          self.resultSearchController.searchBar.sizeToFit()
          self.tableView.tableHeaderView = self.resultSearchController.searchBar
  
      }
  
      override func didReceiveMemoryWarning()
      {super.didReceiveMemoryWarning()
      }
  
  
  
      func query()
      {
          let query = PFQuery(className:"_User")
          query.findObjectsInBackgroundWithBlock { (results: [PFObject]?, error: NSError?) -&gt; Void in
              if error != nil {
                  if let objects = results! as [PFObject]! {
                      for object in objects {
                          let userName = object.objectForKey("firstName") as! String
                          self.searchResults.append(userName)
                          self.tableView.reloadData()   //&lt;-- must reloadData()
                      } } }
          }
  
  
  
  
  
      // MARK: - Table view data source
   func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int
      {
          return 1
      }
  
     func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
          return searchResults.count
      }
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell
      {
          let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
  
          cell.textLabel?.text = searchResults[indexPath.row]
  
          return cell
      }
  
  
  
     func updateSearchResultsForSearchController(searchController: UISearchController)
      {
          self.searchResults.removeAll(keepCapacity: false)
  
          let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
          let array = (self.searchResults as NSArray).filteredArrayUsingPredicate(searchPredicate)
          self.searchResults = array as! [String]
  
          self.tableView.reloadData()
      }
  
  }
  }
  </code></pre>