Reputation: 2329
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?
Upvotes: 13
Views: 7028
Reputation:
You need to alloc and init point
:
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
Upvotes: 15