I'm calling the DispatchQueue.main.asyncAfter
method after I modify a property of an object (I'm firing it with KVO). I'm only showing a confirm view for a second and then run a block which do another things on the UI (pops a viewcontroller). The problem is that when i call this from a UICollectionViewCell
works fine, but when i call this method from another particular UICollectionViewCell
in my app, it freezes up. The method is implemented in a extension of UIView
.
public func showConfirmViewWith(title: String!, frame: CGRect? = screenBounds, afterAction: (() -> Void)?) {
let confirm = ConfirmationView(frame: frame!, title: title)
self.addSubview(confirm)
confirm.checkBox?.setCheckState(.checked, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1) ) {
if afterAction != nil {
afterAction!()
}
confirm.removeFromSuperview()
}
}
When it freezes the code inside the Dispatch never gets called, I have a breakpoint inside, but never gets to that point.
UDPATE Here's the stack trace when i pause the execution: