Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-view cast view type error #158

Open
SpectatorNan opened this issue Mar 16, 2021 · 0 comments
Open

multi-view cast view type error #158

SpectatorNan opened this issue Mar 16, 2021 · 0 comments

Comments

@SpectatorNan
Copy link

SpectatorNan commented Mar 16, 2021

// course view source
let courseViewSource = ClosureViewSource { (view: StudyCar2CouseView, data: StudyCarCourseListModel, index: Int) in
            view.model = data
               view.tapBtn = { model in
                   self.tapApplyCourse <= model
               }
            }
// coach view source
        let coachViewSource = ClosureViewSource { (view: StudyCar2CoachView, data: ClassCoachModel, index: Int) in
            view.model = data
               view.tapBtn = { model in
                   self.tapApplyCoach <= model
               }
            }
// empty space view source
        let emptyViewSource = ClosureViewSource { (view: UIView, model: StudyCar2ApplyViewTypeProtocol, index: Int) in
            
        }

// size provider
        let sizeSource = { (index: Int, viewType: StudyCar2ApplyViewTypeProtocol, collectionSize: CGSize) -> CGSize in
            if viewType is StudyCarCourseListModel || viewType is ClassCoachModel {
                return CGSize(width: kScreenWid-30.fitR, height: 70.fitR)
            }
            return CGSize(width: 50, height: 50)
          }


        listView.provider = BasicProvider(dataSource: dataSource,
                             viewSource: ComposedViewSource(viewSourceSelector: { (viewType) in
                                if viewType is StudyCarCourseListModel {
                                        return courseViewSource
                                }
                                if viewType is ClassCoachModel {
                                    return coachViewSource
                                }
                                return emptyViewSource
                            }),
                             sizeSource: sizeSource
        )

when change data source

occur cast view type error:
Could not cast value of type 'StudyCar2CouseView' to 'StudyCar2CoachView'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant