I am trying to show multiple points on maps.
I tried
DisplayMap *ann = [[DisplayMap alloc] init];
for( int i =1;i<=5;i++ ){
region.center.latitude = 26.438047+i;
region.center.longitude = 50.116422+i;
ann.title = [NSString stringWithFormat:@"title %d",i)];
ann.subtitle =[NSString stringWithFormat:@"subtitle %d",i)];
ann.image = [NSString stringWithFormat@"image_%d.png",i];
ann.coordinate=region.center;
[mapView addAnnotation:ann];
}
[ann release];
this code but only the last pin is on the map.
Can I solve this by listArray or somethink like that ? If I can, how can I create Array for an object with objective-c ?
You want to create DisplayMap object for each annotation
modify your code as below
}
this will work
Or you can use array