I have a method like this:
internal func handlePan(_ sender: UIPanGestureRecognizer) {
if (sender.state == .began) {
let initialPanPoint = sender.location(in: collectionView)
findDraggingCellByCoordinate(initialPanPoint)
} else if (sender.state == .changed) {
let newCenter = sender.translation(in: collectionView!)
updateCenterPositionOfDraggingCell(newCenter)
} else {
if let indexPath = draggedCellPath {
// finishedDragging(collectionView!.cellForItem(at: indexPath)!)
finishedDragging((collectionView?.cellForItem(at: indexPath))!)
}
}
}
And I am getting a crash on
finishedDragging((collectionView?.cellForItem(at: indexPath))!)
fatal error: unexpectedly found nil while unwrapping an Optional value
How can I unwrap this? Please help me. Thanks.