Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add an annotation to MKMapView using an MKPointAnnotation?

Tags:

I am trying to figure out how to add an instance of MKAnnotation to a MKMapView. I can't figure out what I am doing wrong...everything seems to go fine until I actually try and add the annotation to the mapView. Then I receive a SIGABRT error. Here is my code:

lon = [[attributeDict objectForKey:@"long"] doubleValue];
lat = [[attributeDict objectForKey:@"lat"] doubleValue];
 MKPointAnnotation *point;
 CLLocation *theLocation = [[CLLocation alloc]initWithLatitude:lat longitude:lon];
 CLLocationCoordinate2D location;
 location.latitude = lat;
 location.longitude = lon;
 [point setCoordinate:(location)];
 [point setTitle:businessName];

 //ITS RIGHT HERE THAT I GET THE ERROR
 [theMap addAnnotation:point];

Do you have to set the region of the map first or something?