I'll let you work out how to write a for-loop in objective-C because there are literally hundreds of sources for that on the web already. What you need to do is decide how you are going to get your data into an array to loop through. Once you've worked that out the following code is a more efficient version of yours, with these thoughts
- You're doing this in viewDidLoad but the map may not have had time to get the user's location properly. You'd be better off adding all the annotations now and then when the delegate method for receiving a new location gets called you then loop through the
[mapView annotations]
array setting all the labels. - Speaking of which. Both region1 and region2 set
lbl
's text. Each one just overwrites the last. Do you expect to have 1000 labels or do you expect to just see the text for the last region you added to the map? - Why do you zoom to each region? Do you really expect the map to zoom in to each of the 1000 points one-by-one? When it's all done you'll be left looking at the 1000th region and ignoring all the other points
- Why would you set the delegate 1000 times?
.
DisplayMap *ann1 = [[DisplayMap alloc] init];
ann1.title = @" istanbul";
ann1.subtitle = @"esenler";
ann1.coordinate = CLLocationCoordinate2DMake(39.9828000, 26.3033200);
[mapView addAnnotation:ann1];
CLLocation *pinLocation1 = [[CLLocation alloc] initWithLatitude:ann1.coordinate.latitude longitude:ann1.coordinate.longitude];
CLLocationDistance distance1 = [pinLocation1 distanceFromLocation:userLocation];
if(distance1<20000)
{
[lbl setText: [NSString stringWithFormat:@"Distance to point %4.2f m.",distance1]];
}