0

If I specifiy the type of my parameter of a then handler as so...

.then { (things: [Thing]) -> Void in

then I get the error...

Cannot convert value of type '[Thing] -> Void' to expected argument type '(AnyObject) -> AnyPromise'

Is it possible to do what I'm attempting or do I need to cast the parameter in the body of the handler?

If you look here then the Objective-C code shows setting the parameter to an NSArray, which is, at least, not any object.

.then(^(NSArray *fetchedKittens){
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189

1 Answers1

1

One must specify the required type using the promise's generic parameter.

public func MyAsyncFunction() -> Promise<[Thing]>

And its not necessary to type the parameter to the then handler.

.then { things -> Void in
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189