4
votes

I am using RxSwift for my iOS app.

I have a function which returns an Observable of items called Repository.

func search(query: String) -> Observable<Repository>

Basically it makes a network request to github to download the repositories given a search query.

Now, when I call this function, I follow the example in RxSwift documentation:

search(queryText).subscribeNext({ repo in
            print(repo)
        })

But Xcode says

Cannot invoke 'subscribeNext' with an argument list of type '((Repository) -> ())'

That's weird because that's what Xcode suggests to sue when I use autocompletion. I already tried clean and re-build. I get the same kind of error even if I use another subscribe method.

So, what's wrong with this?

1

1 Answers

4
votes

The function subscribeNext is of type

((E) -> Void) -> Disposable

The closure you provide is of correct type. Maybe the place you call subscribeNext is not expecting a Disposable?