Подтвердить что ты не робот

Как добавить аннотацию к MKMapView с помощью MKPointAnnotation?

Я пытаюсь выяснить, как добавить экземпляр MKnnotation в MKMapView. Я не могу понять, что я делаю неправильно... все кажется прекрасным, пока я не попытаюсь добавить аннотацию к mapView. Затем я получаю ошибку SIGABRT. Вот мой код:

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];

Вам нужно сначала установить область карты или что-то еще?

4b9b3361

Ответ 1

Вам нужно выделить и init point:

MKPointAnnotation *point = [[MKPointAnnotation alloc] init];