ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.37k stars 4.17k forks source link

Type 'inout UICollectionView' does not conform to protocol 'ReactiveCompatible'. #1517

Closed YunyueLin closed 6 years ago

YunyueLin commented 6 years ago

:warning: If you don't have something to report in the following format, it will probably be easier and faster to ask in the slack channel first. :warning:

:warning: Please take you time to fill in the fields below. If we aren't provided with this basic information about your issue we probably won't be able to help you and there won't be much we can do except to close the issue :( :warning:

If you still want to report issue, please delete above statements before submitting an issue.

Short description of the issue:

bind error.

Expected outcome:

bind dataSource to collectionView

What actually happens:

notice error: Type 'inout UICollectionView' does not conform to protocol 'ReactiveCompatible'

Self contained code example that reproduces the issue:

  viewModel.models.asObservable()
            .bind(to: collectionView.rx.items(dataSource: dataSource))
            .disposed(by: DisposeBag())

// If we can't get a self contained code example that reproduces the issue, there is a big chance we won't be able
// to help you because there is not much we can do.
//
// `Self contained code example` means:
//
// * that we should be able to just run the provided code without changing it.
// * that it will reproduce the issue upon running

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

4.0.0

Platform/Environment

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

Xcode version:

  9.1

:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:

Installation method:

I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)

Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)

YunyueLin commented 6 years ago

But 'collectionView.rx.itemSelected' have no error.

tarunon commented 6 years ago

Hi @YunyueLin , What is type of viewModel.models? I have seen this error when I made binding with wrong Observable type and collectionView.rx.items.

YunyueLin commented 6 years ago

Hi @tarunon in the VM let models = Variable<[FabricDataModel]>([]) .

and in the V. let dataSource = RxCollectionViewSectionedReloadDataSource<SectionModel<String,FabricDataModel>>

tarunon commented 6 years ago

Hmm, could you please change models type as Variable<[SectionModel<String, FabricDataModel>]> ?

YunyueLin commented 6 years ago

...thanks.