Sometimes, when I call this code when the UICollectionView is not ready (Instantly after calling collectionView.reloadData() ), it resets the application
let sectionHeaderAttributes: UICollectionViewLayoutAttributes = self.collectionView.layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath)!;
Application termination due to the uncaught exception "NSInternalInconsistencyException", reason: "no UICollectionViewLayoutAttributes instance for -layoutAttributesForSupplementaryElementOfKind: UICollectionElementKindSectionHeader on path {length = 2, path = 0 - 0} '
How to verify that a UICollectionView is βreadyβ before I call the code? How do we protect to prevent a failure?
source share