2011-11-02 11 views
13

Estoy intentando averiguar cómo agregar una instancia de MKAnnotation a un MKMapView. No puedo entender lo que estoy haciendo mal ... todo parece ir bien hasta que intento agregar la anotación al mapView. Entonces recibo un error SIGABRT. Aquí está mi código:Cómo agregar una anotación a MKMapView utilizando una anotación MKPoint?

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

¿Tiene que establecer primero la región del mapa o algo así?

Respuesta

14

Necesitas alloc e init point:

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

Oh Dang me siento tonto, no sé cómo me perdí eso. Muchas gracias – Rob

Cuestiones relacionadas