Reputation: 948
I have an rx
observable
returning a Bool
that I need to bind to a SegmentedControl
's selectedSegmentIndex
. The function
looks like this:
func getLockPower() -> Observable<Bool> {
do {
return try doorModeService.getDoorLockPower().map { $0.rawValue == 1 }.asObservable()
} catch {
return .error(error)
}
}
And I have tried binding
it to my SegementedControl
like this:
lockViewModel.getLockPower()
.bind(to: lockInstalledSegmentController.rx.selectedSegmentIndex)
.disposed(by: disposeBag)
But I get the error
:
No exact matches in call to instance method 'bind'
I don't think I get the syntax, and I haven't been able to find any source on how it should look like. Any suggestions?
Upvotes: 0
Views: 114
Reputation: 948
Alright, I worked it out. The index obviously need an Int
, so instead of mapping to Bool
I mapped to an Int
and it worked.
Upvotes: 0