title: I want to make video app light weight in swift
body: <p>Following is code of photo app.</p>
  
  <pre><code>  class VideoList_TableViewController: UITableViewController {
      var videoAssets:PHFetchResult&lt;PHAsset&gt;?
      var imageManager:PHImageManager?
      override func viewDidLoad() {
          super.viewDidLoad()
          self.imageManager = PHImageManager()
  
      }
  
  
      // MARK: - Table view data source
  
      override func numberOfSections(in tableView: UITableView) -&gt; Int 
      {
  
        // here i am fetching assets 
         videoAssets = PHAsset.fetchAssets(with: .video, options:nil)
          return 1
      }
  
      override func tableView(_ tableView: UITableView, 
      numberOfRowsInSection section: Int) -&gt; Int {
       print((videoAssets?.count)!)
          return  (videoAssets?.count)!
      }
  
      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "videoList_Table_Cell", for: indexPath) as! videoList_TableView_Cell_Controller
          if (!cell.didLoaded) {
          cell.didLoaded = true
          cell.asset = videoAssets?[indexPath.row]
          cell.imageManager = self.imageManager
          }
          return cell
      }
  
      override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         let cell = tableView.cellForRow(at: indexPath) as! videoList_TableView_Cell_Controller
  
                      let playerController = AVPlayerViewController()
                      let player = AVPlayer(url: cell.videoUrl!)
                      playerController.player = player
                      self.present(playerController, animated: true, completion: nil)
                      playerController.player?.play()
            }
  }
  </code></pre>
  
  <p>videoList_TableView_Cell_Controller</p>
  
  <pre><code>class videoList_TableView_Cell_Controller: UITableViewCell {
      var imageManager:PHImageManager?
      var videoUrl:URL?
      var didLoaded =  false
      var asset:PHAsset? {
          didSet {
              DispatchQueue.global().async {
                  self.imageManager?.requestAVAsset(forVideo: self.asset!, options: nil, resultHandler: { (vAsset, audio, info) in
                      let avUrl = vAsset as? AVURLAsset
                      let vurl = avUrl?.url
                      let imageGenerator = AVAssetImageGenerator(asset:vAsset!)
                      let time = CMTimeMakeWithSeconds(1.0, 1)
                      var actualTime : CMTime = CMTimeMake(0, 0)
                      let myImage = try! imageGenerator.copyCGImage(at: time, actualTime: &amp;actualTime)
                      DispatchQueue.main.async {
                          self.videoUrl = vurl
                          self.videoTypeLbl.text = vurl?.pathExtension
                          self.videoNameLbl.text = vurl?.lastPathComponent
                          self.videoDurationLbl.text = String(CMTimeGetSeconds((vAsset?.duration)!))
                          self.imageV.image = UIImage(cgImage:myImage)
                      }
                  })
              }
          }
      }
      @IBOutlet weak var imageV: UIImageView!
      @IBOutlet weak var videoTypeLbl: UILabel!
      @IBOutlet weak var videoDurationLbl: UILabel!
      @IBOutlet weak var videoNameLbl: UILabel!
  }
  </code></pre>
  
  <p>This is code for Video playing app in swift3 + xcode 8.2. The problem is that when i run this code my app take too much memory. i think this is happing because i am fetching all video assets at once. Is there any good way to fetch assets?</p>