title: Swift progress bar completedUnitCount and totalUnitCount
body: <p>I don't know if I understood completedUnitCount and totalUnitCount well, I will describe you my problem.</p>
  
  <p>Declaration of progress bar:</p>
  
  <pre><code>@IBOutlet weak var progressBar: UIProgressView!
  let progress = Progress(totalUnitCount: 5)
  </code></pre>
  
  <p>This '5' makes no sense but I put it just to test filling of progress bar.</p>
  
  <p>I want to when I click on button below, to make that button disappear and make progressbar appear on button's place. By default, progressbar is hidden and button is not.<br> It works well, but problem is because I want to dismiss current VC when completedUnitCount is equal to totalUnitCount.<br>
  When I select 5 cardsets, my completedUnitCount is 5 so it is equal to totalUnitCount.
  It starts to fill progressBar and dismisses VC before it is fulfilled. <br>
  Here is my code, I think you don't have to pay attention on Realm stuff, and cardsets in just an array loaded from API and selected ones should be posted in realmTable and it works OK:</p>
  
  <pre><code>@IBAction func btnDownload(_ sender: Any) {
      print("button download pressed")
  
      let realm = try! Realm()
  
      for id in cardsetIds {
          for cardset in cardsets {
              if id == cardset.id &amp;&amp; cardset.cards != "0" {
                  let newSet = CardsetTable()
                  newSet.cards = cardset.cards
                  newSet.size = cardset.size
                  newSet.title = cardset.title
                  newSet.id = cardset.id
  
                  try? realm.write { realm.add(newSet) }
  
                  btnDownload.isHidden = true
                  progressBar.isHidden = false
  
                  progress.completedUnitCount += 1
                  let progressFloat = Float(self.progress.fractionCompleted)
  
                  self.progressBar.setProgress(progressFloat, animated: true)
              }
          }
      }
      if progress.completedUnitCount == progress.totalUnitCount {
  
          self.dismiss(animated: true, completion: nil)
      }
  }
  </code></pre>