title: Select and Pass Multiple Images in an Api request Swift
body: <p>Im new to swift and im trying to figure out a way to select multiple images and pass them as array in a API request.I tried to use DKImagePickerController, in which im able to select multiple images and even preview them but i have no idea how to pass them to an api as an array.
  The code is as follows:</p>
  
  <pre><code>import UIKit
  
  
  class CameraTabViewController: UIViewController,UICollectionViewDataSource, UICollectionViewDelegate{
  
  
  
   override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      @IBAction func saveCamBtn(_ sender: Any) {
          let parent = self.parent as! DiaryEntryViewController
          parent.CameraView.isHidden  = true
      }
  
      @IBAction func selectPhotoBtn(_ sender: Any) {
          let pickerController = DKImagePickerController()
          pickerController.defaultSelectedAssets = self.assets
          pickerController.didCancel = { ()
          }
  
          pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
              self.updateAssets(assets: assets)
          }
          self.present(pickerController, animated: true)
      }
      var pickerController: DKImagePickerController!
  
      var assets: [DKAsset]?
  
      @IBOutlet var previewView: UICollectionView!
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int{
  
          return self.assets?.count ?? 0
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
          let asset = self.assets![indexPath.row]
          var cell: UICollectionViewCell?
          var imageView: UIImageView?
          if asset.isVideo {
              cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellVideo", for: indexPath)
              imageView = cell?.contentView.viewWithTag(1) as? UIImageView
          } else {
              cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellImage", for: indexPath)
              imageView = cell?.contentView.viewWithTag(1) as? UIImageView
          }
  
          if let cell = cell, let imageView = imageView {
              let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
              let tag = indexPath.row + 1
              cell.tag = tag
              asset.fetchImageWithSize(layout.itemSize.toPixel(), completeBlock: { image, info in
                  if cell.tag == tag {
                      imageView.image = image
                  }
              })
          }
          return cell!
      }
  
      func updateAssets(assets: [DKAsset]) {
          self.assets = assets
          self.previewView?.reloadData()
       }
   }
  </code></pre>