Fix intermittent crash

// FREEBIE
This commit is contained in:
Michael Kirk 2017-10-19 19:51:32 -07:00
parent 6db5895269
commit a01de44917

View file

@ -281,9 +281,14 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCellReuseIdentifier, for: indexPath)
guard indexPath.row < imageInfos.count else {
Logger.warn("\(TAG) indexPath: \(indexPath.row) out of range for imageInfo count: \(imageInfos.count) ")
return cell
}
let imageInfo = imageInfos[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCellReuseIdentifier, for: indexPath)
guard let gifCell = cell as? GifPickerCell else {
owsFail("\(TAG) Unexpected cell type.")
return cell