Object A is responsible for releasing any references to other objects (Object B, Object C, etc) when it is deallocated-- this doesn't happen automatically.
This is done in the -dealloc
method on the object:
- (void)dealloc
{
[propertyB release];
[propertyC release];
[super dealloc];
}
(or if the properties are read/write and maked as retain
, you can substitute [self setPropertyB:nil]
, etc).
So what will happen is that when all references to Object A go away, it's deallocated, in turn reducing the reference count on properties B and C. If those objects are only owned by Object A, they, too, will end up being deallocated as a result.
(This is true of all iPhone OS development which you've tagged. I assume you're not talking about the garbage-collected environment on the Mac, which has different rules and behavior and does do some things automatically.)
copy
. – Madi