From 34a85527de0e111c4bf1b15cfa57e701d421bb01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20S=C3=A1nchez?= Date: Sun, 6 Nov 2016 19:38:12 +0000 Subject: [PATCH] Avoid crash when receiving a nil indexPath (#248) --- .../ChatController/BaseChatViewController+Presenters.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Chatto/Source/ChatController/BaseChatViewController+Presenters.swift b/Chatto/Source/ChatController/BaseChatViewController+Presenters.swift index b2b4e60..22595e0 100644 --- a/Chatto/Source/ChatController/BaseChatViewController+Presenters.swift +++ b/Chatto/Source/ChatController/BaseChatViewController+Presenters.swift @@ -89,7 +89,10 @@ extension BaseChatViewController: ChatCollectionViewLayoutDelegate { } @objc(collectionView:canPerformAction:forItemAtIndexPath:withSender:) - open func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool { + open func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath?, withSender sender: Any?) -> Bool { + // Note: IndexPath set optional due to https://github.com/badoo/Chatto/issues/247. SR-2417 might be related + // Might be related: https://bugs.swift.org/browse/SR-2417 + guard let indexPath = indexPath else { return false } return self.presenterForIndexPath(indexPath).canPerformMenuControllerAction(action) }