tags:

views:

135

answers:

1

Code: geoCoder =[[MKReverseGeocoder alloc] initWithCoordinate:UserLocation];

where to release geoCoder though i release in dealloc method it give me memory leak

A: 

I have this code. I made sure it was actually allocated before I tried to release it, I also set it to nil.

- (void)dealloc
{
    if(address!=nil) {
     address = nil;
     [address release];
    }

    // releae the map delegate otherwise it will try and call our classes with no data.
    map.delegate = nil;
    [super dealloc];
}
John Ballinger
I hope you release it before you set it to nil.
Terry Wilcox
1. You set address = nil and send release message to nil object? Why? address may be allocated. then deallocated. But after that address is not nil
oxigen
Actually good point, I have looked at this answer on StackOverflow.http://stackoverflow.com/questions/1211018/objective-c-release-dealloc-and-the-self-referenceI think I should have it in the opposite order.[address release]; address = nil;The nil might not be needed but I don't think it is bad.Thanks for the comments, I am still learning as well on this stuff. Cheers John.
John Ballinger