With the help of MKAnnotation, this problem can be solved. Thanks to @Craig and Vishal Kurup !
Create an annotation class as a subclass of NSObject.
in Annotation.h:
@interface Annotation : NSObject <MKAnnotation>
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, assign) NSString *title;
@property (nonatomic, assign) NSString *subtitle;
@end
It should conform to MKAnnotation and the three properties are the ones that are required when conforming to MKAnnotation class. Declare those and synthesize them in the .m file.
In the MapHistoryViewController implementation file, we need to add few lines of codes to view the annotation at the required coordinates.
MapHistoryViewController.m:
@interface MapHistoryViewController (){
CLLocationCoordinate2D annotationCoord;
Annotation *annotation;
}
@end
@implementation MapHistoryViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// To define coordinate for the annotation
annotationCoord.latitude = mapHistoryLocation.coordinate.latitude;
annotationCoord.longitude = mapHistoryLocation.coordinate.longitude;
annotation = [Annotation alloc];
annotation.coordinate = annotationCoord;
annotation.title = streetAnnotation;
// to display the annotation
[self.mapHistoryView addAnnotation:annotation];
// where mapHistoryView is my MKMapView object
}
//You can set the region too, if you want the map to be focused on the coordinates you have provided
//Hope this will help the people with the same question :)