I'm trying to use PromiseKit v6 in iOS Swift 5 app but I trip on a very basic issue. The code below throws a compiler error:
let p1 = Promise<String> { seal in
seal.resolve("Foo"); /// Referencing instance method 'resolve' on 'Resolver'
/// requires the types 'String' and 'Void' be equivalent
}
I suspect this is something utterly stupid but what's wrong here?
You should check https://mxcl.dev/PromiseKit/news/2018/02/PromiseKit-6.0-Released/ where the changes are described:
Promise.init We altered the main initializer:
Promise { fulfill, reject in
//… } You now have:
Promise { seal in // seal.fulfill(foo) // seal.reject(error) // seal.resolve(foo, error) }
so seal.fulfill("Foo")
will work in your case