RxSwift: Type 'inout UITextField' does not conform to protocol 'ReactiveCompatible'

⚠️ 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. ⚠️

Short description of the issue: Previously in swift 2.x I was using someTextField.rx_text

Then it Changed to (in swift 3.0 update) someTextField.rx.textInput.text

But now it is giving me this error

when I updated (from pods) RxCocoa 3.0.0-rc.1 (was 3.0.0-beta.2) RxSwift 3.0.0-rc.1 (was 3.0.0-beta.2)

// 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


**Xcode version**:

Xcode version goes here


**Expected outcome**:

  _what you expect to happen goes here_

**What actually happens**:

  _what actually happens goes here_

: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**:
  - [*] CocoaPods
  - [ ] Carthage
  - [ ] Git submodules

**I have multiple versions of Xcode installed**:
  (so we can know if this is a potential cause of your issue)
  - [ ] yes (which ones)
  - [*] no

**Level of RxSwift knowledge**:
  (this is so we can understand your level of knowledge
    and formulate the response in an appropriate manner)
  - [ ] just starting
  - [ ] I have a small code base
  - [*] I have a significant code base

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

I am trying to get observable string from searchBar but I am constantly getting this error. Any help will be appreciated.

 var latestRepositoryName: Observable<String> {
        return searchBar.rx
            .text
            .throttle(0.5, scheduler: MainScheduler.instance)
            .distinctUntilChanged
    }

I am getting error Type 'inout UISearchBar' does not conform to protocol 'ReactiveCompatible'.

Thanks @sergdort

Resolved it using RxOptional filterNil() transformer.

latestRepositoryName must be of type Observable<String?> or you must explicitely handle it here by using map function and passing you handler to handle optional string For eg:

var latestRepositoryName : Observable<String>{
        return searchBar.rx.text.throttle(0.5, scheduler : MainScheduler.instance).map(){text -> String in
           if(text == nil){
             return ""
          }else{
       return text!
   }

}
}