CATransaction.setCompletionBlock is not executed when inserting a cell containing a looping animation

6 days ago 3
ARTICLE AD BOX

To correct a failed server request, I'm re-inserting a row in my tableview. The cell in question has a looping animation in one of its subviews/layers, so it's my understanding that setCompletionBlock never gets called because the animations inside haven't completed.

Is there a way around this, maybe telling the completion block to ignore a specific animation?

This is a simplified version of the code:

CATransaction.begin() CATransaction.setCompletionBlock{ [unowned self] in //completion code 1 Task { let success = await serverCall() if !success { CATransaction.begin() CATransaction.setCompletionBlock{ //completion code 2 //never gets called } users.insert(user, at: indexPath.row) tableView.insertRows(at: [indexPath], with: .left) CATransaction.commit() } } } users.remove(at: indexPath.row) tableView.deleteRows(at: [indexPath], with: .left) CATransaction.commit()

Thank you!

Read Entire Article