Post

Replies

Boosts

Views

Activity

Reply to Crash in iOS18
I Found out some situation will be crash in iOS 18. When u want to get cell or header(footer) by calling dequeueCell or dequeueSupplementaryView. And which isn't in collectionView dataSource function like, 'cellForRow' or viewForSupplementaryElementOfKind, It will be crash!!! So, if u have a function call getFootView() like below: func getFootView(indexPath: IndexPath) -> RangePriceFootView? { return collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "FOOTER", for: indexPath) } Call this function at viewForSupplementaryElementOfKind, it is legal. func collectionView( _ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath ) -> UICollectionReusableView { let footer = getFootView(indexPath: indexPath) // footer do something return footer } but if u call this from other place than viewForSupplementaryElementOfKind, it will be crash func updateUI() { let footer = getFootView(indexPath: indexPath) // do something } This warning below tell us, call use -[UlCollectionView cellFortemAtindexPath:] or -[UlCollectionView supplementaryViewForElementKind:atIndexPath:] when u are not in config function. Thread 1: "Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UlCollectionView cellForltemAtindexPath:] or -[UlCollectionView supplementaryViewForElementKind:atindexPath:].
2w