This is a cardCollectionView app, I am trying to delete item with longpress and show a delete button in item. I can delete item already, but my item doesn't reload to an empty place. I found that the problem is because there is a protocol function never working.
Here's my protocol:
@objc protocol ActionDelegation:class {
func deleteCell(_ indexPath:IndexPath, _ cellView:MyCollectionViewCell)
func hideAllDeleteBtn()
func showAllDeleteBtn()    
}
The hideAllDeleteBtn() and showAllDeleteBtn() function are working well, but deleteCell(_ indexPath:IndexPath, _ cellView:MyCollectionViewCell) function never works.
weak var delegation : ActionDelegation!
I try to print() here, but never run in this function at all (in MyCollectionViewCell class)
func animationDidStop(_ theAnimation: CAAnimation!, finished flag: Bool){
    delegation.deleteCell(path, self)
}
here is ViewController class
I did cell.delegation = self in one of my function
It should work after I tap delete button with a disspare animation,
func deleteCell(_ indexPath:IndexPath, _ cellView:MyCollectionViewCell){            print("1")
    myCollectionView.performBatchUpdates({ () -> Void in
        print("2")
        self.cellArray.removeObject(at: indexPath.row)
        self.myCollectionView.deleteItems(at: [indexPath])
        print("3")
    }, completion: {(flag:Bool) in
        print("4")
        self.myCollectionView.reloadData()
        print("5")   
    })
}
yup...this function is never working, if this is function working then empty place should not be empty. FYI the other two protocol functions are working, why only this one can't ?
Edit
This is the animation part, it is in a Animation class which extends NSObject
 class Animation: NSObject {  
   func fadeAnimation(view:UIView){
    let animation = CATransition() 
    animation.delegate = view as? CAAnimationDelegate 
    animation.duration = 0.5 
    view.layer.add(animation, forKey: nil) 
    view.isHidden = true 
}}
it will call in MyCollectionViewCell 
like below (in MyCollectionViewCell)
let animation = Animation()
func setAnimation(){
    animation.fadeAnimation(view: self)
}
when I delete the item, it can delete and with fade animation

 
     
    
