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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to