0

Code:

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

Where to release GeoCoder though I release in dealloc method? It give me memory leak...

kit
  • 1,166
  • 5
  • 16
  • 23

1 Answers1

-1

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
  • 7,380
  • 5
  • 41
  • 51
  • I hope you release it before you set it to nil. – Terry Wilcox Aug 12 '09 at 13:34
  • 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 Aug 12 '09 at 14:49
  • Actually good point, I have looked at this answer on StackOverflow. http://stackoverflow.com/questions/1211018/objective-c-release-dealloc-and-the-self-reference I 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 Aug 13 '09 at 01:25