I am coding multiple annotations into a project. Currently I have 30 annotations, and growing. I'm wondering if there is a simplier way of having to create a annotation.h and annotation.m classes for each single annotation.
Currently in my map view controller, I create the annotation objects and place them in an array, which has been working well for me but as you could imagine, its a lot of code to manage once you have tons of annotations, not to mention tons of classes.
So for example, one of the annotation classes looks like this:
Annotation.h:
//Annotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface Annotation : NSObject {
}
@end
Annotation.m:
//Annotation.m
#import "Annotation.h"
@implementation Annotation
-(CLLocationCoordinate2D)coordinate;
{
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = -45.866416;
theCoordinate.longitude = 170.519931;
return theCoordinate;
}
-(NSString *)title
{
return @"Title";
}
-(NSString *)subtitle
{
return @"Subtitle";
}
-(void)dealloc
{
[super dealloc];
}
@end
I'm thinking of reading in a CSV file with all the annotations would be the best way to go, any option I choose will result in me rewriting a lot of code, which is why I'm asking this question before I do anything. Does anyone have any suggestions?