Its very common question everybody familiar with, but I'm still not understand it fully.
If Object A owns (have a strong property of) Object B, and Object B have a strong property of object A, there is retain cycle, and no object can be released and there is a memory leak.
But, what if Object A instead will point for Object C instead of Object B, therefore another address in memory?
As far as i know, strong properties do something like follow:
- (void)setObject:(id)newObject{
if (_newObject == newObject){
return; //
}
NSObject *oldObject = _newObject;
_newObject = [newObject retain];
[oldObject release];
}
So, what if we point instead for Object C, isn't in that case memory for Object B will be released? What if both Objects (A and B) will instead set nil
object? Is there still would be retain cycle with memory leak? With old value "floating" somewhere in memory?
I know, that has been discussed many times, but i still can't get "whole picture" in my head. I would appreciate any clarification in that matter.