iOS - Help with nasty memory leak
iOS - Help with nasty memory leak
- Subject: iOS - Help with nasty memory leak
- From: Philip Vallone <email@hidden>
- Date: Sat, 27 Nov 2010 09:33:59 -0500
Hi,
I have implemented a dragable annotation in my app. I am getting a 100% memory leak that has me puzzled. I was hoping that someone can provide some guidance. The leak is at:
MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease];
Here is the entire method:
- (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease];
if (draggablePinView) {
draggablePinView.annotation = annotation;
} else {
if ([draggablePinView isKindOfClass:[AnnotationView class]]) {
((AnnotationView *)draggablePinView).mapView = MapView;
}
}
((MKPinAnnotationView *)draggablePinView).pinColor = MKPinAnnotationColorGreen;
((MKPinAnnotationView *)draggablePinView).animatesDrop = YES;
return draggablePinView;
}
The analizer says the leak is AnnotationView. So I can't see anything in AnnotationView that would cause the leak:
#import "AnnotationView.h"
#import "CurrentLocationAnnotation.h"
@implementation AnnotationView
@synthesize hasBuiltInDraggingSupport;
@synthesize mapView;
- (void)dealloc {
[super dealloc];
}
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
self.hasBuiltInDraggingSupport = [[MKPinAnnotationView class] instancesRespondToSelector:NSSelectorFromString(@"isDraggable")];
if (self.hasBuiltInDraggingSupport) {
if ((self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) {
[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
}
}
self.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
self.canShowCallout = YES;
UIImage *image = [UIImage imageNamed:@"gps_add.png"];
UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease];
self.leftCalloutAccessoryView = imgView;
self.image = image;
return self;
}
@end
Thanks for any help and guidance.
Phil_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden