title: UIView.animate not executed in PHPhotoLibrary.shared().performChanges
body: <p>I have been working on the following code for the entire day now and simply cannot find the problem. I would like to save a video and upon completion make certain buttons or spinners (dis-)appear. All the buttons are setup in the <code>viewDidLoad</code> and so to say exist (they're optionals, therefore also the optional chaining). My problem is the animations in the <code>if</code> clause are never executed. Only sometimes if I place breakpoints before every line of code, it works which really makes me wonder (btw: the breakpoints don't indicate anything unusual). Further, if I replace the code of the <code>if success2 == true</code> with the code of the <code>else</code> (<code>if success2 == false</code>), it works (after the alert pops up). I pretty much quadruple-checked my code and just cannot find what I am doing wrong. Has anyone an idea as to what could be the problem and how it could be solved? </p>
  
  <p>Sorry for the huge block of code:</p>
  
  <pre><code>PHPhotoLibrary.shared().performChanges({
      if let assetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url) {
          let assetCollectionChangeRequest = PHAssetCollectionChangeRequest(for: albumAssetCollection)
          let enumeration: NSArray = [assetChangeRequest.placeholderForCreatedAsset!]
          assetCollectionChangeRequest?.addAssets(enumeration)
      }
  }, completionHandler: { (success2: Bool, error2: Error?) in
      if success2 == true {
          // prompt that the video has been saved
          UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
              if let checkButton = self.checkButton, let saveSpinner = self.saveSpinner, let resetButton = self.resetButton {
                  saveSpinner.alpha = 0
                  checkButton.alpha = 1
                  resetButton.alpha = 1
              }
          }) { (completed: Bool) in
              if completed == true {
                  if let saveSpinner = self.saveSpinner {
                      saveSpinner.stopAnimating()
                      self.timeLimitReached = false
                      self.changeClipsCount()
                  }
                  UIView.animate(withDuration: 0.5, delay: 3, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
                      if let checkButton = self.checkButton, let saveButton = self.saveButton {
                          checkButton.alpha = 0
                          saveButton.alpha = 1
                      }
                  }) { (completed: Bool) in }
              }
          }
      } else {
          // prompt that the video has not been saved
          let alertController = UIAlertController(title: "Something failed!", message: "The video could not be saved.", preferredStyle: .alert)
          let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
          alertController.addAction(okAction)
          self.present(alertController, animated: true, completion: {
              UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
                  if let saveButton = self.saveButton, let saveSpinner = self.saveSpinner {
                      saveButton.alpha = 1
                      saveSpinner.alpha = 0
                  }
              }) { (completed: Bool) in
                  if let saveSpinner = self.saveSpinner {
                      saveSpinner.stopAnimating()
                      self.timeLimitReached = false
                  }
              }
          })
      }
  })
  </code></pre>