+1  A: 

If you are using MKMapView, then you need to create your own MKAnnotation to add to the map. The annotation class implement the following instance methods:

- (NSString *)title - to return the title of the pin, which is usually the first line

- (NSString *)subtitle - to return the subtitle of the pin, which is usually the second line.

notnoop
I have already both methods as below.-(NSString *)subtitle { return [NSString stringWithFormat:@"%f",coordinate.latitude];}-(NSString *)title { return [NSString stringWithFormat:@"%f",coordinate.longitude]; }-(id)initWithCoordinate: (CLLocationCoordinate2D) c { coordinate=c; NSLog(@"%f %f",c.latitude,c.longitude); return self;}What should i change??
sugar
+4  A: 

You've got two options here:

  1. If all you want to do is take a latitude/longitude and present it as an address on the map, you'll need to use the MKReverseGeocoder class which will spit out a MKPlacemark that can then be added to your MKMapView using addAnnotation:.

  2. If you've got some class of "thing" you'd like added to the map such as a "Person", you should make the class conform to the MKAnnotation protocol (i.e. it needs a coordinate, title and subtitle property). You can then implement the mapView:viewForAnnotation: method on your MKMapView delegate and return a custom subclass of MKAnnotationView. This will get added to the map when your "Person" becomes visible in the map view.

Nathan de Vries
A: 
sugar
+1  A: 

Thanks a lot, you made my day, i was very surprised what it is happening when i found that my subtitle is not taking nsstring stringwithformat, it was crashing and it was taking it when i assigned direct same hardcoded value in string format. very strange , now atleast it is not crashing thanks a lot for the solution

Naren