In my code I do,
ClassA *reference = [[ClassA alloc] init];
[reference invokeMethod];
reference = nil;
[reference release];
Without the reference = nil I know it releases the memory cos its normal way to do so. But in this situation if we make the reference nil and release the memory later does it remove the earlier memory consumed for object creation?
Thank You
No.
release = niljust makes the memory it originally points to unaccessible; it won’t remove the memory consumed. (Also, this causes the[reference release];statement afterward a no-op.)