title: After parsing jSON data send another viewController using swif and load UITableViewCell
body: <p>I have successfully downloaded JSON data at <code>DataManager.swift</code>. After downloading data, I want to store it into an array or dictionary the <code>**&quot;listings&quot;**</code> value and send it to <code>ViewController.swift</code> and load it into a UITavleViewCell. I am following the MVC framework. I have tried several ways but I failed.</p>
  <p><strong>JSON data</strong></p>
  <pre><code>{
  &quot;backfillCount&quot;: 150,
  &quot;breadCrumbs&quot;: [
  {3 items},
  {3 items},
  {3 items}
  ],
  &quot;dealerNewCount&quot;: 420,
  &quot;dealerUsedCount&quot;: 319,
  &quot;enhancedCount&quot;: 589,
  &quot;facetCountMap&quot;: {25 items},
  &quot;listings&quot;: [
  {
  &quot;accidentHistory&quot;: {4 items},
  &quot;advantage&quot;: true,
  &quot;backfill&quot;: false,
  &quot;badge&quot;: &quot;GREAT&quot;,
  &quot;bedLength&quot;: &quot;Unspecified&quot;,
  &quot;bodytype&quot;: &quot;Sedan&quot;,
  &quot;cabType&quot;: &quot;Unspecified&quot;,
  &quot;certified&quot;: false,
  &quot;currentPrice&quot;: 31985,
  &quot;dealer&quot;: {21 items},
  &quot;dealerType&quot;: &quot;NEW&quot;,
  &quot;displacement&quot;: &quot;2.4 L&quot;,
  &quot;distanceToDealer&quot;: 4.410725307988554,
  &quot;drivetype&quot;: &quot;FWD&quot;,
  &quot;engine&quot;: &quot;4 Cyl&quot;,
  &quot;exteriorColor&quot;: &quot;Blue&quot;,
  &quot;firstSeen&quot;: &quot;2019-12-12&quot;,
  &quot;followCount&quot;: 5,
  &quot;following&quot;: false,
  &quot;fuel&quot;: &quot;Gasoline&quot;,
  &quot;hasViewed&quot;: false,
  &quot;id&quot;: &quot;19UUB1F69LA000169CDOTUSNR4120191212&quot;,
  &quot;imageCount&quot;: 25,
  &quot;images&quot;: {5 items},
  &quot;interiorColor&quot;: &quot;Red&quot;,
  &quot;isEnriched&quot;: false,
  &quot;listPrice&quot;: 31985,
  &quot;make&quot;: &quot;Acura&quot;,
  &quot;mileage&quot;: 1550,
  &quot;model&quot;: &quot;TLX&quot;,
  &quot;monthlyPaymentEstimate&quot;: {7 items},
  &quot;mpgCity&quot;: 23,
  &quot;mpgHighway&quot;: 32,
  &quot;newTopOptions&quot;: [10 items],
  &quot;noAccidents&quot;: true,
  &quot;oneOwner&quot;: true,
  &quot;onePrice&quot;: 33640,
  &quot;onePriceArrows&quot;: [4 items],
  &quot;onlineOnly&quot;: false,
  &quot;ownerHistory&quot;: {4 items},
  &quot;personalUse&quot;: true,
  &quot;recordType&quot;: &quot;ENHANCED&quot;,
  &quot;sentLead&quot;: false,
  &quot;serviceHistory&quot;: {5 items},
  &quot;serviceRecords&quot;: true,
  &quot;sortScore&quot;: 191.65,
  &quot;stockNumber&quot;: &quot;H200327A&quot;,
  &quot;subTrim&quot;: &quot;Unspecified&quot;,
  &quot;topOptions&quot;: [10 items],
  &quot;transmission&quot;: &quot;Automatic&quot;,
  &quot;trim&quot;: &quot;Technology&quot;,
  &quot;vdpUrl&quot;: &quot;https://www.carfax.com/vehicle/19UUB1F69LA000169&quot;,
  &quot;vehicleCondition&quot;: &quot;Used&quot;,
  &quot;vehicleUseHistory&quot;: {4 items},
  &quot;vin&quot;: &quot;19UUB1F69LA000169&quot;,
  &quot;year&quot;: 2020
  },
  {56 items},
  {56 items},
  {56 items},
  {57 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {57 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items},
  {56 items}
  ],
  &quot;page&quot;: 1,
  &quot;pageSize&quot;: 25,
  &quot;relatedLinks&quot;: {2 items},
  &quot;searchArea&quot;: {8 items},
  &quot;searchRequest&quot;: {8 items},
  &quot;seoUrl&quot;: &quot;Used-Acura_m1&quot;,
  &quot;totalListingCount&quot;: 739,
  &quot;totalPageCount&quot;: 30
  }
  </code></pre>
  <p><strong>Download Manager</strong></p>
  <pre><code>import Foundation
  
  
  protocol CarDataManagerDelegate {
      func didUpdateData()
      func didFailWithError(error: Error)
  }
  
  struct DataManager{
      var delegate:CarDataManagerDelegate?
          
      //MARK: - Fetch Car information
      func fetechCarInformation(){
          let urlString = &quot;URL&quot;
          performRequest(with: urlString)
      }
      
      //MARK: - Perform API Request From carfax-for-consumers
      func performRequest(with urlString: String){
          // create a URL
          if let url = URL(string: urlString){
              
              // create url session
              let session = URLSession(configuration: .default)
              
              // Give the session task
              let task = session.dataTask(with: url) { (data, response, error) in
                  if error != nil{
                      print(error!)
                      //self.delegate?.didFailWithError(error: error!)
                      return
                  }
                  if let safeData = data{
                      self.parseJSON(carData: safeData)
                  }
              }
              // start task
              task.resume()
          }
      }
      
      func parseJSON(carData: Data){
          let decoder = JSONDecoder()
          do {
              let decodedData = try decoder.decode(CarsFeed.self, from: carData)
             print(decodedData)
          } catch {
              print(&quot;MY Error: \(error)&quot;)
          }
      }
  }
  </code></pre>
  <p><strong>Model</strong></p>
  <pre><code>import Foundation
  
  struct CarData: Decodable{
      let seoUrl: String
      let totalListingCount: Int
      let listings: [Listings]
      let picture:[Listings]
  }
  
  struct SearchArea: Decodable {
      let city: String
  }
  
  struct DealerNewCount: Decodable {
      let dealerNewCount: Int
  }
  
  
  struct Listings: Decodable {
      let badge: String
  }
  </code></pre>
  <p><strong>ViewController</strong></p>
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      var dataManager = DataManager()
      
      @IBOutlet weak var carInfoTable: UITableView!
      
    
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
          
          dataManager.delegate = self
          
          dataManager.fetechCarInformation()
          
          //MARK: - calling setUpTableView Function
          setupTableView()
      }
      
      //MARK: - Setup or Register UItableView
      
      func setupTableView() {
          carInfoTable.dataSource = self
          carInfoTable.register(UINib(nibName: K.cellNibName, bundle: nil), forCellReuseIdentifier: K.cellReuseIdentifier)
          carInfoTable.separatorStyle = .none
          carInfoTable.contentInsetAdjustmentBehavior = .never
          carInfoTable .reloadData()
      }
  }
  
  //MARK: - UITextFieldDelegate
  extension ViewController: UITableViewDataSource{
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return pictures.count
      }
      
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = carInfoTable.dequeueReusableCell(withIdentifier: K.cellReuseIdentifier, for: indexPath) as! CarInfoTableViewCell
          cell.cinfigureCell(picture: pictures[indexPath.row], title: titles[indexPath.row], mobileNumber: numbers[indexPath.row])
          return cell
      }
      
  }
  
  //MARK: - CarDataManagerDelegate
  extension ViewController: CarDataManagerDelegate{
      func didUpdateData() {
          
      }
      func didFailWithError(error: Error) {
          
      }
      
  }
  </code></pre>