Is it safe to use snapshot section identifiers for creating the UICollectionViewCompositionalLayout?

Viewed 49

I am creating my layout based on the section identifiers, which I am appending to the snapshot like mentioned. Is it safe to use like this?

var compositionalLayout: UICollectionViewLayout {
        let layout = UICollectionViewCompositionalLayout { (sectionIndex: Int,
                                                            layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in
            let width = layoutEnvironment.container.effectiveContentSize.width
            
            guard let sectionIdentifiers = self.snapShot?.sectionIdentifiers else {
                return CustomLayoutSection.gridWithFixedHeightLayoutSection()
            }
            return sectionIdentifiers[sectionIndex].createSection()
        }
        return layout
    }
0 Answers
Related