Want to get the item based on my indexpath rxcollectionviewdatasource

 Problem:

I want to get the item from rxcollectionviewdatasource from multiple sections with multiple items.

Solution


   func collectionView(_ collectionView: UICollectionViewlayout collectionViewLayout: UICollectionViewLayoutsizeForItemAt indexPath: IndexPath) -> CGSize {

        if let item = try? dataSource.model(at: indexPath) as? MyItem {

            switch item {

            case .model1(_):

                return CGSize.zero

                

            case . model2(infolet info):

                return CGSize(width: 320, height: 100)

                

            case . model3(info: _):

                return CGSize(width: 320, height: 100)

                

            case . model4(info: _):

                return CGSize(width: 320, height100)

            }

        }

        return CGSize.zero

    }


ViewModel:

typealias SectionOfSearch = SectionModel<CollViewSearchSection,SearchCollViewItem>


enum CollViewSearchSection {

    case model1

    case model2

    case model3

    case model4

}


enum SearchCollViewItem {

    case model1(info: String)

    case model2(info: Int)

    case model3(info: Int)

    case model4(info: String)

    

}


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift