I have a function right now that is determining the hide behavior of a UILabel: func shouldHideLabel() -> Bool
.
I need to retrieve data from a web request to determine whether or not to hide this label, so inside of shouldHideLabel()
I'm making a call to a function func webRequestDataIsValid() -> Bool
.
webRequestDataIsValid()
is doing a web request with a closure, returning an object, and the object has a variable isValid
on it, which is returning true or false.
My goal is to wait on this isValid
flag to be returned to me, return from webRequestDataIsValid
with true or false, and then use that return value to return from the original shouldHideLabel
function.
I'm using a completion handler inside of shouldHideLabel
to wait on the data from webRequestDataIsValid
, but I'm not sure how to wait on returning inside of shouldHideLabel
for my closure to finish. It seems like you can't return from a function while inside of a closure.
Any help is much appreciated. Thank you!