title: download images from url to image array and show in table view swift
body: <p>I am facing trouble getting image from my json url.</p>
  
  <p>this is my json:</p>
  
  <pre><code>"bank_details": [
      {
          "id": 1,
          "logo": "http://mortgagemarket.ae/webApi/public/mortgage_bank_icons/noorebank.png",
          "name": abc company
  
      }
  ]
  </code></pre>
  
  <p>my swift code to parse the image is this:</p>
  
  <pre><code>import UIKit
  class BanksViewController: UIViewController, UITableViewDelegate,UITableViewDataSource {
  
  final let BANKS_URL = "http://www.mortgagemarket.ae/webApi/api/manage_interest_rates"
      @IBOutlet weak var tableView: UITableView!
  
  var bankicon = [String]()
  var bankname = [String]()
  var bankid = [Int]()
  
  let stringid: String = ""
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.displayFromDb()
      tableView.dataSource = self
      tableView.delegate = self
  
  
  }
  
  
  
  func displayFromDb()
  {
      let tokensp = UserDefaults.standard.string(forKey: "tokenKey")
      let url = NSURL(string: BANKS_URL+"?token="+tokensp!)
  
      print(url)
      URLSession.shared.dataTask(with: (url as?URL)!, completionHandler: {(data,response,error) -&gt;
          Void in
  
          if let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary
          {
  
              print(jsonObj.value(forKey: "bank_details")!)
  
              if let messageArray = jsonObj.value(forKey: "bank_details") as? NSArray
              {
                  print(jsonObj.value(forKey: "bank_details")!)
  
                  for message in messageArray
                  {
                      if let messageDict = message as? NSDictionary
                      {
  
                          if let data = data {
  
  
                              if let bankname = messageDict.value(forKey: "bank_name")
                              {
                                  self.bankname.append(bankname as! String)
                                  print(bankname)
  
                              }
  
  
                              if let banklogo = messageDict.value(forKey: "logo")
                              {
  
                                  self.bankicon.append(banklogo as! String)
                                  print(banklogo)
  
                              }
  
                              if let bankid = messageDict.value(forKey: "id")
                              {
                                  self.bankid.append(bankid as! Int)
                                  print(bankid)
  
                              }
  
                              OperationQueue.main.addOperation({
                                  self.tableView.reloadData()
                              })
  
                          }
                      }
  
                  }
  
              }
  
          }
  
  
      }).resume()
  
  }
  
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return (bankname.count)
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! BanksTableViewCell
  
  
  
    cell.bankicon.image = bankicon[indexPath.row] as? UIImage
      cell.bankname.text = bankname[indexPath.row]
  
  
      return (cell)
  
  }
  
  }
  </code></pre>
  
  <p>now When I run this code it is showing blank table cells. I dont know how to get image from url and display the images in table view cell. Please someone help me.
  this is my whole code to get the all the json data into table view cell. Please someone help me</p>