views:

14

answers:

1

Hi,

What is the difference of releasing the object outside and inside a dealloc method? When it will be appropriate to specify release of the object in the dealloc method, pls can u specify the differences...

A: 

Do you mean releasing an object that is contained with another object? If so I will have a stab at this:

If you perform this operation outside the dealloc method then you would need to ensure that subsequent messages to the containing instance (the instance that sent the release message) do not manipulate the released instance. Otherwise you will start to get strange behaviour.

If you perform the release within the dealloc method of the containing object then you are kinda guaranteed that the containing instance is finished with the object because it is finished with (because it is being dealloc)

Hope this makes sense / answer you question

JC