weakLinks are commonly used to avoid storing loops in the graph of application objects. I understand this part. Now I would like to take another step and understand how they work under the hood.
Searching a bit, I read that when I use the qualifier __weak, the variable associated with this qualifier is registered in the auto-detection pool, but what does it mean? Why is the object registered in the pool? What type of pool is used? Is this the main pool or some other specially created one?
When I use this code:
id _weak myWeakObj = [[NSObject alloc] init];
the compiler gives me a warning, which I can fix with:
id _strong myStrongObj = [[NSObject alloc] init];
id _weak myWeakObj = myStrongObj;
So, based on the previous question, what happens to the object referenced myStrongObj? If possible, I would like to know what the compiler code looks like?
source
share