Bridging from Objective C to Swift with PromiseKit -
using promisekit 2.0 swift 1.2, i'm trying use pmkpromise created in objective c swift.
objective c code:
@interface footest : nsobject + (pmkpromise *)promise; @end
swift code (i've tried number of variations, none of work. 1 closest example given @ http://promisekit.org/promisekit-2.0-released/):
footest.promise().then { (obj: anyobject?) in self.obj = obj }
compiler error: cannot invoke 'then' argument list of type '((anyobject?) -> _)'
this doesn't work either:
footest.promise().then { (obj: anyobject?) -> anypromise in return anypromise() }
similar error: "cannot invoke 'then' argument list of type '((anyobject?) -> anypromise)'"
there 2 different promise classes in promisekit, 1 swift (promise<t>
) , 1 objc (anypromise
). swift ones generic , objective-c cannot see generic classes, why there two.
if foo.promise()
meant used in both objc , swift doing right thing. if intend use promise in swift suggest rewriting promise<t>
.
to use objective-c anypromise
(pmkpromise
deprecated alias anypromise
: prefer anypromise
) in swift code must splice existing chain.
someswiftpromise().then { _ -> anypromise in return someanypromise() }.then { (obj: anyobject?) -> void in //… }
there should way start anypromise, add later today:
someanypromise().then { (obj: anyobject?) -> void in //… }
expect 2.1 update. [edit: 2.1 pushed above then
added]
Comments
Post a Comment