title: How to extract specific data from multiple responses using Alamofire
body: <p>I am building an app in order to learn swift. My app is making a request to yelpApi. The response shows informations (names , location , address etc...) for multiple restaurant base on the location. I am able to display the restaurant name, address, type for one restaurant. How could I display the data for multiples restaurants. I created array and append but I am always getting the data for one restaurant. </p>
  
  <p>Thanks for all answers </p>
  
  <p>My Class model </p>
  
  <p>'''</p>
  
  <pre><code>Class ApiRestaurantDataModel {
  
      var restaurantName : String?
      var restaurantLocation : String?
      var restaurantType : String?
      var restaurantRating : Int?
  
      init(restaurantName: String?, restaurantLocation: String?, restaurantType: String?) {
          self.restaurantName = restaurantName
          self.restaurantLocation = restaurantLocation
          self.restaurantType = restaurantType
      }
  
  
  }
  </code></pre>
  
  <p>'''</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! DiscoverTableViewCell
  
  
  
          cell.discoverImage.image = images
          cell.restaurantNameLabel.text = apiDataModel[indexPath.row].restaurantName
          cell.restaurantLocationLabel.text = apiDataModel[indexPath.row].restaurantLocation
          cell.typeLabel.text = apiDataModel[indexPath.row].restaurantType
  
          return cell
      }
  
  
      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          // #warning Incomplete implementation, return the number of rows
          return apiDataModel.count
      }
  
  // Networking 
  
   func search(url: String, parameters : [String:String]) {
          let headers: HTTPHeaders = ["Authorization":"Bearer \(apiKey)"]
          Alamofire.request(url, method: .get, parameters: parameters, headers: headers ) .responseJSON{
              URLResponse in
              //print(URLResponse)
              if URLResponse.result.isSuccess {
                  let yelpDataJSON = JSON(URLResponse.value!)
                print(yelpDataJSON)
                  self.updateYelpData(Json: yelpDataJSON)
  
              }else{
                  print("error")
              }
  
          }
      }
  
  
  
  func updateYelpData(Json : JSON){
  
         if  let nameJSON = Json["businesses"][0]["name"].string {
  
         let  locationJSON = Json["businesses"][0]["location"]["display_address"][0].stringValue
        let typeJSON = Json["businesses"][0]["categories"][0]["alias"].stringValue
  
            let data = ApiRestaurantDataModel(restaurantName: nameJSON, restaurantLocation: locationJSON, restaurantType: typeJSON)
          apiDataModel.append(data)
  
  
          print(apiDataModel.count)
         let imageUrlJSON = Json["businesses"][0]["image_url"].string
          imageURL = imageUrlJSON!
  
  
  
  
          loadImage()
           tableView.reloadData()
          }else{
              print("error")
          }
      }
  </code></pre>
  
  <p>Json response value </p>
  
  <pre><code>{
    "businesses" : [
      {
        "distance" : 235.19630722374731,
        "rating" : 4.5,
        "phone" : "+525555218815",
        "display_phone" : "+52 55 5521 8815",
        "url" : "https:\/\/www.yelp.com\/biz\/el-cardenal-ciudad-de-m%C3%A9xico-2?adjust_creative=A4ydpSOHv8wBNquTDeh0DQ&amp;utm_campaign=yelp_api_v3&amp;utm_medium=api_v3_business_search&amp;utm_source=A4ydpSOHv8wBNquTDeh0DQ",
        "price" : "$$",
        "name" : "El Cardenal",
        "location" : {
          "address2" : "",
          "state" : "DIF",
          "zip_code" : "06000",
          "country" : "MX",
          "city" : "Ciudad de México",
          "address1" : "Calle de la Palma 23",
          "display_address" : [
            "Calle de la Palma 23",
            "06000 Ciudad de México, CDMX",
            "Mexico"
          ],
          "address3" : null
        },
        "is_closed" : false,
        "id" : "Vr7pWwSpDGtr7Dk_wJJzhA",
        "review_count" : 221,
        "transactions" : [
  
        ],
        "alias" : "el-cardenal-ciudad-de-méxico-2",
        "coordinates" : {
          "longitude" : -99.135253714120793,
          "latitude" : 19.433706059965399
        },
        "categories" : [
          {
            "title" : "Mexican",
            "alias" : "mexican"
          }
        ],
        "image_url" : "https:\/\/s3-media3.fl.yelpcdn.com\/bphoto\/7hNTc7V1q3737rxkTf-drQ\/o.jpg"
      },
      {
        "distance" : 116.24557090185914,
        "phone" : "+525555212048",
        "rating" : 4,
        "display_phone" : "+52 55 5521 2048",
        "url" : "https:\/\/www.yelp.com\/biz\/caf%C3%A9-de-tacuba-m%C3%A9xico?adjust_creative=A4ydpSOHv8wBNquTDeh0DQ&amp;utm_campaign=yelp_api_v3&amp;utm_medium=api_v3_business_search&amp;utm_source=A4ydpSOHv8wBNquTDeh0DQ",
        "price" : "$$",
        "name" : "Café de Tacuba",
        "location" : {
          "address3" : "",
          "address1" : "Calle de Tacuba 28",
          "country" : "MX",
          "address2" : "Col. Centro",
          "city" : "México, D.F.",
          "display_address" : [
            "Calle de Tacuba 28",
            "Col. Centro",
            "06010 México, D.F.",
            "Mexico"
          ],
          "zip_code" : "06010",
          "state" : "DIF"
        },
        "is_closed" : false,
        "id" : "DBQvLnAqV-MXPkA0XMi5aQ",
        "review_count" : 232,
        "transactions" : [
  
        ],
        "alias" : "café-de-tacuba-méxico",
        "coordinates" : {
          "longitude" : -99.137562322962197,
          "latitude" : 19.4356993121581
        },
        "categories" : [
          {
            "title" : "Mexican",
            "alias" : "mexican"
          }
        ],
        "image_url" : "https:\/\/s3-media1.fl.yelpcdn.com\/bphoto\/_ooR7uHUx2okb7EQd12Ojw\/o.jpg"
      }
  
  '''
  </code></pre>