I've looked at some comments to questions on stackoverflow about using [weak self] and [unowned self]. I need to be sure I understand correctly.
I am using the latest Xcode - Xcode 13.4, the latest macOS - macOS Monterey 12.4, and I'm writing code compatible with iOS 12.0 to the latest iOS 15.
First of all, am I correct that memory that has a strong reference to it is owned by whichever the strong reference belongs to?
Also, and this is what I really need to know, I want to know what happens if I use [weak self] in at the beginning of a closure, and then I have the statement guard let `self` = self else { return }. I believe the guard statement, if the condition succeeds, assigns the reference self holds to the newly declared strong reference named self in the let `self part of the guard statement. Is that correct?
What that leads me to ask is, What happens at the end of the closure. Am I correct that even though the newer self holds a strong reference, the memory the strong reference points to is deallocated once the code in the closure has executed the last statement in the closure, because the newer self with the strong reference is declared within the closure itself, and is deallocated along with all memory that had been allocated for that closure.
I think I got all of this right. If not, please let me know.
I am interested in any additional information or any clarifications if you will.