Reputation: 8944
I read about manual & ARC memory management in Objective-C. In below points I am confused which is true about memory management in Objective-C?
Always nil out properties in dealloc under ARC and manual memory management.
Do not have to nil out properties in dealloc under ARC and manual memory management.
nil out properties in dealloc under ARC but not in manual memory management.
Upvotes: 1
Views: 108
Reputation: 14122
Just use ARC and happy days!
However, you should at least be aware of the difference between strong and weak references.
Upvotes: 0
Reputation: 9544
There isn't much reason to use manual memory management in most cases anymore.
But to answer your question, don't nil in dealloc. Instead:
[myObject release];
Upvotes: 1
Reputation: 63157
You never have to "nil" out properties, you just have to release them when doing manual memory management.
When you set a value to nil, you lose track of the old value that was there. That old value stored the address of the object. Now that object continues to exist, but you no longer know its address, and have no way of releasing it.
Release tells an object "I'm no longer using you, and if I'm the last one, then delete yourself". In ARC, retain and release calls are added automatically by the compiler. There's rarely any reason to do that manual memory management yourself anymore. ARC is the way to go.
Upvotes: 1