我能够在我的代码中异步调用AWS lambda函数,如下所示:
var r = IPInputToResourceGetSpots()
r.latitude = 37.8050638 //destination.latitude
r.longitude = -122.2972835 //destination.longitude
r.radius = 1000
let client = IPIOSAppAPIClient.defaultClient()
var results:IPOutputToResourceGetSpots = IPOutputToResourceGetSpots()
client.resourcegetspotsPost(r).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: { (task: AWSTask!) -> AnyObject! in
//Deal with return of AWS function
return task
})
但我想要的是同步调用代码并在调用AWS函数时暂停代码,直到调用完成。我试过更改这一行:
client.resourcegetspotsPost(r).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: { (task: AWSTask!) -> AnyObject! in
使用:
client.resourcegetspotsPost(r).continueWithBlock({ (task: AWSTask!) -> AWSTask! in
但两者似乎都是异步的......