Thank you, My viewForAnnotation was all wrong. I was trying code from this tutorial:
http://trentkocurek.wordpress.com/2010/07/21/ios4-map-kit-draggable-annotation-views/ So, I went back and redid my code, which fixed the memory leak and alleviated the need for a custom Annotation View. - (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"PinIdentifier"]; if (pin == nil) { pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"PinIdentifier"] autorelease]; }else { pin.annotation = annotation; } pin.pinColor = MKPinAnnotationColorGreen; pin.animatesDrop = YES; pin.draggable = YES; pin.canShowCallout = YES; pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; UIImage *image = [UIImage imageNamed:@"gps_add.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease]; pin.leftCalloutAccessoryView = imgView; return pin; } Thanks a bunch, Phil On Nov 27, 2010, at 11:50 AM, Joar Wingfors wrote: > > On 27 nov 2010, at 06.33, Philip Vallone wrote: > >> if ((self = [[MKPinAnnotationView alloc] >> initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) { >> [self >> performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber >> numberWithBool:YES]]; >> } > > > You're replacing the current instance with a new instance here. Is that > intended? While not illegal, it is really unusual to do that. > > If that's intended, you also would have to release the old instance before > replacing it with the new instance (that's the leak). If that was not > intended, you probably should be calling [super initWithAnnotation:annotation > reuseIdentifier:reuseIdentifier], and in any case, you need to make sure that > you *always* call through to the designated initializer of your superclass > somewhere in your init method. > > Finally, why are you calling a method using "-performSelector:withObject:" > here? That seems like a trick to "fix" a compiler warning? If so, you should > think about why the compiler were warning you about that call, and fix it > properly - by adding the required #import statement, by adding the missing > method declaration to the header, or - if all else fails - by casting the > receiver to the appropriate type. > > > j o a r > > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
