In the More iPhone 3 development book, after the author is done with the locationManager delegate method of getting updates, he puts this at the end of that method:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
// some code here
manager.delegate = nil;
[manager stopUpdatingLocation];
[manager autorelease];
}
And similarly, in the MKReverseGeocoder delegate methods, when he's done he does this:
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
//some code here
geocoder.delegate = nil;
[geocoder autorelease];
}
Why do you need to do that in order to clean up memory? I thought the rule was if you alloc/init it, you need to release it. Why does he add the locationManager and geocoder to the autorelease pool? Thanks.