I've just completed my first simple iPhone app; I'm using Instruments to find memory leaks.
I am a little lost as to how to reuse pointers. I have read the Apple documentation, but I still don't understand the correct procedure.
The Apple docs say, "Another typical memory leak example occurs when a developer allocates memory, assigns it to a pointer, and then assigns a different value to the pointer without freeing the first block of memory. In this example, overwriting the address in the pointer erases the reference to the original block of memory, making it impossible to release."
Do I really have to release and create a new pointer each time?
Example creating memory leak on dateFormatter:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// year
[dateFormatter setDateFormat:@"yyyy"];
NSInteger year = [[dateFormatter stringFromDate:date] integerValue];
// month
[dateFormatter setDateFormat:@"MM"];
NSInteger month = [[dateFormatter stringFromDate:date] integerValue];
...
[dateFormatter release];
Thanks for your help!