It doesn't matter. I assume you mean that OBJ_001
owns OBJ_002
owns the NSString instance, and you own all three objects (co-owning the NSString with OBJ_002
and co-owning OBJ_002
with OBJ_001
).
Doing it in reverse order:
- Release NSString instance: Nothing happens, because
OBJ_002
still owns it.
- Release
OBJ_002
: Nothing happens, because OBJ_001
still owns it.
- Release
OBJ_001
: It releases OBJ_002
, which releases the NSString. All three dealloc.
Doing it in the same order:
- Release
OBJ_001
: It releases OBJ_002
, then deallocks. OBJ_002
still exists because you still own it.
- Release
OBJ_002
: It releases the NSString, then deallocks. The NSString still exists because you still own it.
- Release NSString instance: It deallocks.
Either way, all three instances dealloc. There is no difference.
I prefer the reverse order, but that's purely a style choice.