title: UICollectionView so much slow to load
body: <p>The instance I've successfully called the images from array JSON returned object the UICollection is very slow to load especially if it has main images.</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
  
      let childDict: NSDictionary = subCategoryData .object(at: indexPath.row) as! NSDictionary
  
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listcollectionview", for: indexPath) as! subCategoryCollectionViewCell
  
      subCategoryTable.register(UINib(nibName: "subCategoryCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "listcollectionview")
  
      let subimages = childDict.object(forKey: "image") as! String!
      let data = NSData(contentsOf: NSURL(string: subimages!)! as URL)
      cell.backgroundImageView.image = UIImage(data: data! as Data)
  
      cell.categoryName.text = (subCategoryMenuData [indexPath.row] as? String)
      cell.categoryName?.textColor = UIColor.white
      cell.categoryName?.backgroundColor = UIColor().HexToColor(hexString: GREYBLACK)
  
      return cell;
  }
  </code></pre>
  
  <p>I tried as well the dispatch.queue in didselectitemat when calling the segue but this didn't solve the problem</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  
      let childDict: NSDictionary = subCategoryData .object(at: indexPath.row) as! NSDictionary
  
      if (childDict.object(forKey: "children") as! NSArray).count &gt; 0{
          let sb = UIStoryboard(name: "Main", bundle: nil)
          let initViewController: subCategory? = (sb.instantiateViewController(withIdentifier: "subCategory") as? subCategory)
          initViewController?.subCategoryData = (childDict.object(forKey: "children") as! NSArray)
          initViewController?.subName = childDict.object(forKey: "name") as! String!
          initViewController?.subId = childDict.object(forKey: "path") as! String!
          initViewController?.modalTransitionStyle = .flipHorizontal
          self.navigationController?.pushViewController(initViewController!, animated: true)
      }else{
  
          categoryName = childDict .object(forKey: "name") as! String
          categoryId = childDict .object(forKey: "path") as! String
          DispatchQueue.main.async {
              self.performSegue(withIdentifier: "productCategorySegue",sender: self)
          }
      }
  
  
  }
  </code></pre>
  
  <p>It some times take 30 seconds to load</p>