What's the correct way to destroy various objects in the c lens?

I have this object that contains references to other objects:

1) considers
2) view controllers
3) dictionaries
4) arrays
5) custom objects.

what's the best way to destroy it? do I need to create a destroy method that will deal with destroying its various properties?
are there any special things to do in each of these types, or did I just set them all to zero?
Note. I am using ARC.

thanks
nimrod

+3


source to share


2 answers


It depends on whether you are using Automatic Reference Counting (ARC) or not.

Without ARC, you must override the dealloc method and release the objects you own.



With ARC, you can simply set your main object to nil

. ARC will take care of freeing the object and all its other objects.

+6


source


Since you are using ARC, you don't have to worry too much about freeing objects unless there is a defined save cycle.



You can send nil to your object as yourObject=nil;

, which will make it null and be released later.

+1


source







All Articles