Here is a solution that uses 3 arrays to hold the categories of annotations and selects the appropriate one based on the segmented controller
ViewController.h
@interface PWViewController : UIViewController
@property (strong,nonatomic) IBOutlet MKMapView *myMapView;
@property (strong,nonatomic) IBOutlet UISegmentedControl *mySegmentedControl;
@property int currentAnnotation;
@property (strong,nonatomic) NSMutableArray *locationArrays;
-(IBAction)setMap:(id)sender;
ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.locationArrays=[[NSMutableArray alloc]init];
//Create the region
MKCoordinateRegion myRegion;
//Center
CLLocationCoordinate2D center;
center.latitude = 52.369331;
center.longitude = 4.893467;
//Span
MKCoordinateSpan span;
span.latitudeDelta = 0.04f;
span.longitudeDelta = 0.04f;
myRegion.center = center;
myRegion.span = span;
[self.myMapView setRegion:myRegion animated:YES];
//Annotation
CLLocationCoordinate2D location;
Annotation *myAnn;
NSMutableArray *category1 = [[NSMutableArray alloc]init];
NSMutableArray *category2 = [[NSMutableArray alloc]init];
NSMutableArray *category3 = [[NSMutableArray alloc]init];
myAnn = [[Annotation alloc]init];
location.latitude = 52.369331;
location.longitude = 4.893467;
myAnn.coordinate = location;
myAnn.title = @"Nes";
myAnn.subtitle = @"Nes";
[category1 addObject:myAnn];
//TODO create and add other 'category 1' locations in the same way
[self.locationArrays addObject:category1];
myAnn = [[Annotation alloc]init];
location.latitude = 52.379680;
location.longitude = 4.886858;
myAnn.coordinate = location;
myAnn.title = @"Noordermarkt";
myAnn.subtitle = @"Noordermarkt";
[category2 addObject:myAnn];
//TODO create and add other 'category 2' locations in the same way
[self.locationArrays addObject:category2];
myAnn = [[Annotation alloc]init];
location.latitude = 52.371532;
location.longitude = 4.898080;
myAnn.coordinate = location;
myAnn.title = @"De Wallen";
myAnn.subtitle = @"De Wallen";
[category3 addObject:myAnn];
myAnn = [[Annotation alloc]init];
location.latitude = 52.368585;
location.longitude = 4.886457;
myAnn.coordinate = location;
myAnn.title = @"Bijbels Museum";
myAnn.subtitle = @"Bijbels Museum";
[category3 addObject:myAnn];
//TODO create and add other 'category 3' locations in the same way
[self.locationArrays addObject:category3];
self.currentAnnotation = 0;
[self.myMapView addAnnotations:[self.locationArrays objectAtIndex:0]];
}
-(IBAction)setMap:(id)sender {
int newAnnotations=((UISegmentedControl *) sender).selectedSegmentIndex;
if (newAnnotations != self.currentAnnotation)
{
[self.myMapView removeAnnotations:[self.locationArrays objectAtIndex:self.currentAnnotation]];
[self.myMapView addAnnotations:[self.locationArrays objectAtIndex:newAnnotations]];
self.currentAnnotation = newAnnotations;
}
}