Dangling pointers in objective c - does nil also release memory?

Viewed 4253

What I understand is:

Memory leaks occur when memory has not been freed or "released" Dangling pointers occur when the pointer is NOT set to nil AND the object is released.

my question is: Can setting the object to nil free the memory and clear the pointer reference?

i.e.

Car *myCar = [[Car alloc] initWithCoolRims: YES];
myCar = nil;
//no mem leaks or dang pointers

or does the ARC do this:

Car *myCar = [[Car alloc] initWithCoolRims: YES];
[myCar release];    
myCar = nil;
//no mem leaks or dang pointers

Thankyou

2 Answers
Related