This is the error I am getting on devices with iOS 9 and 10 :
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items before section 9223372036854775807 when there are only 1 sections in the collection view'
The error seems clear to me, however I am unable to understand why this is not happening on devices with iOS 11.
I don't know how to fix it.
Here is my code :
extension MainTileViewController: MainForecastsDelegate {
func mainForecasts(_ forecastVC: MainForecastsViewController!, didChangeWith object: Any!) {
if let cell = self.outletWeatherForecastCollectionView.cellForItem(at: self.currentIndexPath) as? MainTileCollectionViewCell {
// Some stuff...
}
}
The crash happens here. This is a protocol method triggered when the user switch day etc...
Obviously I have an issue with my currentIndexPath.
Here is my initialization :
var currentIndexPath : IndexPath = []
And in the viewDidLoad :
self.currentIndexPath = IndexPath(item: 0, section: 0)
How can I secure my code so that it won't crash ? Can you explain me the changing behavior between collectionView from iOS 9/10 with iOS 11 ones (except prefetching).