I recently took an objective-c test to see how I would do.
Turns out my score wasn’t anywhere near as good as I hoped. That means more studying.
During the test, I was asked this question:
How do you free an object?
A. [obj dealloc];
B. [obj release];
C. None of the above
My choice was A, and I don’t know if it’s correct. The question is confusing: Doesn’t release call dealloc, therefore achieving the same result?
No.
releasedecrements the object’s reference count.You don’t call
deallocdirectly. Callreleaseto decrement the reference count and let the runtime calldeallocwhen the reference count becomes zero.