The question is why the completion block not executed at the line imgURL = url ?? ""
imgURL = url ?? ""
.
When I am debugging, it stops at the line msg.getMediaContentTemporaryUrl
and then all the block are skipped executing the return.
func getImageURL(_ msg:TCHMessage)->String {
var imgURL : String = ""
msg.getMediaContentTemporaryUrl { (result, url) in
imgURL = url ?? ""
print("getImage Function: ",imgURL)
}
return imgURL
}
Looking at the examples of the rest of the languages in the official documentation:
Twilio docs for getMediaContentTemporaryUrl
What you are defining inside the curly brackets is a callback executed asynchronously, so you will get there once the request is done. If you want to stop when you reach that point, you will need to add a breakpoint to the line imgURL = url ?? ""
imgURL = url ?? ""
, for example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.