Lets examine the following example
SomeLib.someAsyncFunction { [weak someVariable] in
if let someVariableU = someVariable {
// now someVariableU is unwrapped and strong reference created , we can use it as regular
}
}
I assume that optional binding has a low level implementation similar(not exactly of course) to something like this
if variable != nil {
return variable!
}
So, my question - is it possible that the object referenced by weak reference will deallocated during optional binding, I mean the last strong reference to the object is "cleared". If so what will happen in this case?
What will happen if the "nil check will pass" and then it will be deallocated, what will happen to "force unwrap"(I used parentheses because I understand that it's not exactly how it works)!
So, can somebody explain if this situation is even possible, and is o than what will happen?