title: How to retrieve images from json array using alamofire?
body: <p>I have been trying to fetch details and images of a product from a server URL.I was able to get the details but not the image because image is a JSONarray.Please help me retrieve the images looking into the code. By the way, i have made use of "Alamofire" library. Thanks much!</p>
  
  <p>JSON below:</p>
  
  <pre><code> {
     "products": [
       {
          "product_id": 2,
          "name": "Ring",
          "description": "&lt;p&gt;    &lt;/p&gt;",
          "price": 674,
          "master_variant_id": 2,
          "cost_currency": "USD",
          "shipping_and_returns": "",
          "city_or_state": null,
          "state_or_province": null,
          "user": {
              "company_name": "Gift Shop",
              "firstname": "giftvendor"
          },
          "master_variant_images": [
              "https://s3.amazonaws.com/webdevapp/app/public/spree/products/2/product/ri1.jpg?1476104874"
          ],
          "variants": [],
          "product_url": "http://staging.giftintime.com/mobile/products/2"
      }
  }
  </code></pre>
  
  <p><strong>below is my code</strong>  </p>
  
  <pre><code>var gifther = [Gifther]()
  
   override func viewDidLoad() {
      super.viewDidLoad()
      tableview.delegate = self
      tableview.dataSource = self
  
      Alamofire.request("http://staging.giftintime.com/mobile/categories/2/subcategories").responseJSON { (response) in
  
          let result = response.result
  
          if let dict = result.value as? Dictionary &lt;String, Any&gt; {
  
              if let giftherdata = dict["products"] as? [Dictionary&lt;String, Any&gt;] {
  
                  for obj in giftherdata {
  
                      let giftintime = Gifther(giftherData: obj)
                      self.gifther.append(giftintime)
                      //print(giftintime)
                  }
                  self.tableview.reloadData()
              }
          }
      }
  }
   public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = self.tableview.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! giftherTableViewCell
  
      let Gift: Gifther
      Gift = gifther[indexPath.row]
  
      //Displaying values
      cell.productnameLbl.text = Gift.productname
      cell.companynameLbl.text = "By  " + Gift.companyname
      cell.priceLbl.text = Gift.price
      cell.currencytypeLbl.text = Gift.currencytype
  
      //cell.imageview?.image = UIImage(named: Gift.imagesUrl)
  
     // cell.selectionStyle = UITableViewCellSelectionStyle.none
  
      //Displaying image
  
  
  
      Alamofire.request(Gift.imagesUrl  ).responseImage { (response) in
          debugPrint(response)
  
          if let image = response.result.value {
  
              cell.imageview.image = image
  
          }
  
      }
  
      /*
  
      Alamofire.request(Gift.imagesUrl as! URLRequestConvertible).responseData { (response) in
          if response.error == nil {
              print(response.result)
          }
  
          if let data = response.data {
              cell.imageview.image = UIImage(data: data)
          }
      }
      */
      return cell
  }    
  </code></pre>
  
  <p><strong>below is my code from another class</strong></p>
  
  <pre><code>class Gifther {
  
  var _productname:String?
  var _price:String?
  var _currencytype:String?
  var _companyname:String?
  var _imagesUrl:String?
  var _productUrl:String?
  
  //product details
  var _descriptionData: String?
  var _shippingAndreturns :String?
  
  var productname:String {
  
      if _productname == nil {
          _productname = ""
  
      }
              return _productname!
  }
  
  var price:String {
  
      if _price == nil {
          _price = " "
  
      }
      return _price!
  }
  
  var currencytype:String {
  
      if _currencytype == nil {
          _currencytype = ""
      }
      return _currencytype!
  }
  
  var companyname:String {
  
      if _companyname == nil {
          _companyname = ""
      }
      return _companyname!
  }
  
  var imagesUrl:String {
  
      if _imagesUrl == nil {
          _imagesUrl = ""
      }
      return _imagesUrl!
  }
  </code></pre>
  
  <p>//Product deails</p>
  
  <pre><code>var productUrl:String {
  
      if _productUrl == nil {
          _productUrl = ""
      }
      return _productUrl!
  }
  
      var descriptionData:String {
  
          if _descriptionData == nil {
              _descriptionData = ""
          }
          return _descriptionData!
      }
  
  var shippingAndreturns:String {
  
      if _shippingAndreturns == nil {
          _shippingAndreturns = ""
      }
      return _shippingAndreturns!
  }
  
  
  
  init(giftherData: Dictionary&lt;String , Any&gt;) {
  
      if let name = giftherData["name"] as? String {
  
          self._productname = name
      }
  
      if let Price = giftherData["price"] as? Float {
          self._price = String(describing: Price)
      }
  
      if let moneyType = giftherData["cost_currency"] as? String {
  
          self._currencytype = moneyType
      }
  
      if let companyname = giftherData["user"] as? Dictionary&lt;String, Any&gt; {
  
          if let name = companyname["company_name"] as? String {
  
              self._companyname = name
          }
      }
  
  
      if let image = giftherData["master_variant_images"] as? NSArray {
  
         print("images are : \(image.count)")
  
          self._imagesUrl =  String(describing: image)
  
      }
  
     //Product details
  
      if let Producturl = giftherData["product_url"] as? String {
  
          self._productUrl = Producturl
  
      }
  
      if let description = giftherData["description"] as? String {
  
          self._productUrl = description
      }
  
      if let shippingAndreturns = giftherData["shipping_and_returns"] as? String {
  
          self._shippingAndreturns = shippingAndreturns
      }
       }
  
  }
  </code></pre>