I'm trying to fetch some data from coreData and display it in collectionView. Pretty basic. I do this on a background thread and then call reloadData on the main, as seen in the images.
But the problem is that sometimes it works and sometimes it doesn't, giving me index out of range. And I observed that when it crashes it enters some delegate method of collection view and not viewWillAppear
Edit: Here Is the code