PICyourBrain
PICyourBrain

Reputation: 10294

How to specify types when calling generic function in swift?

I have defined a function with the following signature:

 public func loginUser(username: String) -> ReactiveCocoa.Signal<String, NSError>

I am trying to call the method toRACSignal and pass it the result of loginUser.

The signatures for toRACSignal are:

 func toRACSignal<T, E>(signal: ReactiveCocoa.Signal<T, E>) -> RACSignal
 func toRACSignal<T, E>(signal: ReactiveCocoa.Signal<T?, E>) -> RACSignal

My attempt looks like this:

  public func RACLoginUser(username: String) -> RACSignal {
     let signal = loginUser(username)
     return toRACSignal(signal)   
  }

but this results in an error saying:

Error:(33, 12) cannot find an overload for 'toRACSignal' that accepts an argument list of type '(Signal)'

What am I doing wrong?

Upvotes: 2

Views: 139

Answers (1)

PICyourBrain
PICyourBrain

Reputation: 10294

I just figured it out. The problem is that String is not an object in Swift. Replace with NSString (or any other object) and it works.

Upvotes: 1

Related Questions