Let’s say I have an object named “foo” with another object named “bar” as property.
When “foo” deallocates, will it automatically remove all references to “bar” so that “bar” deallocates as well? or will “foo” deallocate and “bar” float in memory somewhere? even if all of “bar”‘s references are defined in “foo”.
thanks in advance.
If the
fooobject has any retains on or copies of (thanks Dave)bar, for example when you declare the property as either one of these:You’ll need to release
barwhen you deallocatefoo:The system won’t free
bar‘s memory space for you until you get rid of all references to it (i.e. reference count goes down to 0), so you’ll have to monitor your reference counts and objects yourself.