Refactoring the long-press handler

Because the long-press handler will now be used differently based on the isEditing state of the ViewController, it's a wise idea to separate the two different paths to different methods. The gesture recognizer handler will still make sure that a valid cell and index path are used and after that, it will call out to the correct method. Add the following code to make this separation and add a placeholder for the cell reordering sequence:

@objc func receivedLongPress(gestureRecognizer: UILongPressGestureRecognizer) { 
let tappedPoint = gestureRecognizer.location(in: collectionView)
guard let tappedIndexPath = collectionView.indexPathForItem(at: tappedPoint),
let tappedCell = collectionView.cellForItem(at: tappedIndexPath) else { return }

if isEditing {
reorderContact(withCell: tappedCell, atIndexPath: tappedIndexPath, gesture: gestureRecognizer)
} else {
deleteContact(withCell: tappedCell, atIndexPath: tappedIndexPath)
}
}

func reorderContact(withCell cell: UICollectionViewCell, atIndexPath indexPath: IndexPath, gesture: UILongPressGestureRecognizer) {

}

func deleteContact(withCell cell: UICollectionViewCell, atIndexPath indexPath: IndexPath) {
// cell deletion implementation from before
}

The preceding code demonstrates how there are now two paths with methods that get called based on the edit state. The deleteContact(withCell:UICollectionViewCell, atIndexPath: IndexPath) method is unchanged for the most part, there's just a few variables from the code before that would need to be renamed. This is an exercise for you.