Pin.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface Pin : NSObject{
CLLocationCoordinate2D coordinate;
NSString *subtitle;
NSString *title;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic,retain)NSString *subtitle;
@property (nonatomic,retain) NSString *title;
- (id) initWithCoords:(CLLocationCoordinate2D) coords;
@end
Pin.m #import "Pin.h"
@implementation Pin
@synthesize coordinate;
@synthesize subtitle;
@synthesize title;
- (id) initWithCoords:(CLLocationCoordinate2D) coords{
self = [super init];
if (self != nil)
coordinate = coords;
return self;
}
- (void) dealloc{
[title release];
[subtitle release];
[super dealloc];
}
@end
Luego agregamos al mapa el pin:
CLLocationCoordinate2D pinlocation; pinlocation.latitude = latitude; pinlocation.longitude = longitude; Pin *pin = [[Pin alloc] initWithCoords:pinlocation]; pin.title = self.tituloSel; [mapa removeAnnotations:[mapa annotations]]; [mapa addAnnotation:pin]; [pin release];
No hay comentarios:
Publicar un comentario