DisplayMap.h
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>
@interface DisplayMap : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@end
DisplayMap.m
#import "DisplayMap.h"
@implementation DisplayMap
@synthesize coordinate,title,subtitle;
-(void)dealloc{
[title release];
[super dealloc];
}
@end
I am implementing the above in a map view to show annotations. On the viewdidload, i run through a set of coordinates and display them on the map using the above mentioned annotation class.
for(int i=0;i<[xmlParameter count];i++){
region.center.latitude=(double)[[[xmlParameter objectAtIndex:i]objectAtIndex:3] doubleValue];
region.center.longitude =(double) [[[xmlParameter objectAtIndex:i]objectAtIndex:4] doubleValue] ;
region.span.longitudeDelta = 0.08f;
region.span.latitudeDelta = 0.08f;
DisplayMap *ann = [[DisplayMap alloc] init];
ann.title = [[xmlParameter objectAtIndex:i]objectAtIndex:0];
ann.subtitle = [[xmlParameter objectAtIndex:i]objectAtIndex:1];
ann.coordinate = region.center;
[mapView addAnnotation:ann];
if(i==zoomtoParameter){
[mapView setRegion:region animated:YES];
//showAnnotation=ann;
[mapView selectAnnotation:currentAnnotation animated:YES];
//[mapView selectAnnotation:ann animated:YES];
}
[ann release];
}
Running with instruments with leaks, says there is a DisplayMap leak for 32Bytes in the viewDidLoad method. I can't figure out how; i am releasing the DisplayMap object right after am done with it.
Any suggestions?
Thanks