func foo() -> Bool {
var apiResult : Bool = false
myAPI.bar() { (result: Bool) -> Void in
// some logic in block and local variable assignment
apiResult = result
}
return apiResult
}
Is the value of apiResult guaranteed to be updated by the block passed in?
(I am a college student learning iOS, so please be as informative as possible)
You are passing the closure (block) to the myAPI.bar function. The function may or may not call the closure. If the closure is called then apiResult would change. The change may occur after the function foo returns though, depending on how myAPI.bar is implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With