views:

134

answers:

1

Hi, I have all my annotations(as nsdictionnaries) in an array , and the users add them one by one by tapping on an icon. I want to make it impossible to add more annotations after adding 10 annotations (there is 110).

Is it here i have to make something?:

-(IBAction) plusButtonTapped: (id) sender {

NSDictionary *poiDict = [poiArray objectAtIndex:nextPoiIndex++];
CLLocationCoordinate2D poiCoordinate;
poiCoordinate.latitude = [[poiDict valueForKey:@"workingCoordinate.latitude"] doubleValue];
poiCoordinate.longitude = [[poiDict valueForKey:@"workingCoordinate.longitude"] doubleValue];
MyMapAnnotation *poiAnnotation = [[MyMapAnnotation alloc]
                                  initWithCoordinate:poiCoordinate
                                  title:[poiDict valueForKey:@"Subtitle"]
                                  color:MKPinAnnotationColorRed ];
[mapView addAnnotation:poiAnnotation];
[self adjustMapZoom];

}

Thank you for your help in advance,

teddafan

A: 

Use a mutable array of annotations. Check the length when the button is clicked or disable the button when over your threshhold.

Nick
Thank you for your answer! How would you disable the button?
teddafan
Docs for UIButton are pretty awesome and clear:[yourButton setEnabled: NO];oryourButton.enabled = NO;
Nick