How to get the title and subtitle for a pin when we are implementing the MKAnnotation?

Posted by wolverine on Stack Overflow See other posts from Stack Overflow or by wolverine
Published on 2010-06-16T14:47:56Z Indexed on 2010/06/17 4:23 UTC
Read the original article Hit count: 305

Filed under:
|
|

I have implemented the MKAnnotation as below. I will put a lot of pins and the information for each of those pins are stored in an array. Each member of this array is an object whose properties will give the values for the title and subtitle of the pin. Each object corresponds to a pin. But how can I display these values for the pin when I click a pin??

@interface UserAnnotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;

NSString *title;
NSString *subtitle;
NSString *city;
NSString *province;
}

@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
@property (nonatomic, retain) NSString *city;
@property (nonatomic, retain) NSString *province;

-(id)initWithCoordinate:(CLLocationCoordinate2D)c;

And .m is

@implementation UserAnnotation

@synthesize coordinate, title, subtitle, city, province;

- (NSString *)title
{
 return title;
}

- (NSString *)subtitle
{
 return subtitle;
}

- (NSString *)city
{
 return city;
}

- (NSString *)province
{
 return province;
}

-(id)initWithCoordinate:(CLLocationCoordinate2D)c
{
coordinate=c;
NSLog(@"%f,%f",c.latitude,c.longitude);
return self;
}


@end

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mkmapview