title: How to display the list of data initially in View Controller
body: <p>This is my Pokedex. It works per say... A minor issue I have with this is when you initially open the app, it doesn't show the list of data, just blank. When you enter something in search bar, it appears even when you delete everything and no letters in the search bar.
  I looked for how to display the list initially and compared with a functional code but can't figure out what caused this.
  Any helps and ideas will be appreciated.
  Here is my main ViewController:
  import UIKit</p>
  <pre><code>class ViewController: UITableViewController, UISearchBarDelegate {
      
      @IBOutlet weak var searchBar: UISearchBar!
      var pokemon: [Pokemon] = []
      var filteredData: [Pokemon] = []
     
      func capitalize (text: String) -&gt; String {
          function and followed by the remaining text without the first letter
          return text.prefix(1).uppercased() + text.dropFirst()
      }
      override func viewDidLoad() {
          super.viewDidLoad()
          let url = URL(string: &quot;https://pokeapi.co/api/v2/pokemon?limit=151&quot;)
          guard let u = url else {
              return
          }
  
          URLSession.shared.dataTask(with: u) { (data, reponse, error) in
              guard let data = data else {
                  return
              }
              do {
                  let pokemonList = try JSONDecoder().decode(PokemonList.self, from: data)
                  self.pokemon = pokemonList.results
                  DispatchQueue.main.async {
                      self.tableView.reloadData()
                  }
              }
              catch let error {
                  print(&quot;\(error)&quot;)
              }
          }.resume()
          searchBar.delegate = self
          filteredData = pokemon
      }
      
      override func numberOfSections(in tableView: UITableView) -&gt; Int {
          return 1
      }
  
      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return filteredData.count
      }
      
      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: &quot;PokemonCell&quot;, for: indexPath)
          cell.textLabel?.text = capitalize(text: filteredData[indexPath.row].name)
  
          return cell
      }
      
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          if segue.identifier == &quot;PokemonSegue&quot; {
              if let destination = segue.destination as? PokemonViewController {
                  destination.pokemon = filteredData[tableView.indexPathForSelectedRow!.row]
              }
          }
      }
      func searchBar (_ searchBar: UISearchBar, textDidChange searchText: String) {
          filteredData = []
          if searchText == &quot;&quot; {
              filteredData = pokemon
          }
          else {
              for pokemon in pokemon {
                  if pokemon.name.lowercased().contains(searchText.lowercased()){
                      filteredData.append(pokemon)
                  }
              }
          }
          self.tableView.reloadData()
      }
  }
  </code></pre>