I have a MapAnnotation that I added custom fields to so when the user clicks on the pin I perform a segue to another view controller where I try to set labels to these custom fields. The problem is I'm not getting the values in the veiwcontroller so it's not persisting. I am new to iOS dev so I am probably missing something.
Here is where I set the MapAnnotation
NSArray *json = [NSJSONSerialization JSONObjectWithData:data
options:kNilOptions
error:&error];
for (MapAnnotation *record in json) {
// NSLog(@"%lu", (unsigned long)json.count);
MapAnnotation *temp = [[MapAnnotation alloc]init];
[temp setTitle:[record valueForKey:@"city"]];
[temp setSubtitle:[record valueForKey:@"region"]];
[temp setHeatmap:[record valueForKey:@"iframe_heatmap_url"]];
[temp setPercentViewed:[record valueForKey:@"percent_viewed"]];
[temp setOrg:[record valueForKey:@"org"]];
[temp setEmbedURL:[record valueForKey:@"embed_url"]];
[temp setCoordinate:CLLocationCoordinate2DMake([[record valueForKey:@"lat"]floatValue], [[record valueForKey:@"lon"]floatValue])];
[retval addObject:temp];
Is there something I need to do to persist this to the other view controller? I am simply importing the MapAnnotation class into the view controler and setting the labels text to the fields in my custom class:
Custom Annotation Class
@interface MapAnnotation : NSObject<MKAnnotation>
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy) NSString *org;
@property (nonatomic, copy) NSString *percentViewed;
@property (nonatomic, copy) NSString *heatmap;
@property (nonatomic, copy) NSString *embedURL;
@end