title: How to access and pass annotation properties to another view controller
body: <p>So in my app, I have a mapView that drops pins when the screen is pressed. Once the annotations are dropped, they are placed into an array. There will be multiple pins on the map at one time, and each pin has a identifier property that is an NSNumber. I have another view controller that is pushed onto the stack when the callout button on the annotationView is pressed, and this view has a button that I want to delete the pin from the mapView when pressed. My problem is, I do not know how to pass the identifier of the pin to the second view controller. Here is some code.</p>
  
  <p>This is the method where I drop the pin:</p>
  
  <pre><code>-(void)press:(UILongPressGestureRecognizer *)recognizer
  {
    CGPoint touchPoint = [recognizer locationInView:_worldView];
    CLLocationCoordinate2D touchMapCoordinate = [_worldView convertPoint:touchPoint toCoordinateFromView:_worldView];
  
  geocoder = [[CLGeocoder alloc]init];
  CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
                                                      altitude:CLLocationDistanceMax
                                            horizontalAccuracy:kCLLocationAccuracyBest
                                              verticalAccuracy:kCLLocationAccuracyBest
                                                     timestamp:[NSDate date]];
  [geocoder reverseGeocodeLocation:location
                 completionHandler:^(NSArray *placemarks, NSError *error) {
                     NSLog(@"reverseGeocoder:completionHandler: called");
                     if (error) {
                         NSLog(@"Geocoder failed with error: %@", error);
                     } else {
                         CLPlacemark *place = [placemarks objectAtIndex:0];
                         geocodedAddress = [NSString stringWithFormat:@"%@ %@, %@ %@", [place subThoroughfare], [place thoroughfare], [place locality], [place administrativeArea]];
                         if (UIGestureRecognizerStateBegan == [recognizer state]) {
                             value = [number intValue];
                             number = [NSNumber numberWithInt:value + 1];
                             addressPin = [[MapPoint alloc]initWithAddress:geocodedAddress coordinate:touchMapCoordinate
                                                                     title:geocodedAddress identifier:number];
                             NSLog(@"The identifier is %@", number);
                             [_annotationArray addObject:addressPin];
                             [_worldView addAnnotation:addressPin];
                             NSLog(@"The number of pins in the annotation array is: %u",_annotationArray.count);
                         }
                     }
                 }];
  }
  </code></pre>
  
  <p>This is where I create the second view controller:</p>
  
  <pre><code>-(void)mapView:(MKMapView *)mapView
  annotationView:(MKAnnotationView *)view
  calloutAccessoryControlTapped:(UIControl *)control
  {
    PinViewController *pinViewController = [[PinViewController alloc]init];
    [[self navigationController]pushViewController:pinViewController animated:YES];
  
    pinViewController.label.text = view.annotation.title;
  }
  </code></pre>
  
  <p>Here is my MKAnnotation class:</p>
  
  <pre><code>#import &lt;CoreLocation/CoreLocation.h&gt;
  #import &lt;MapKit/MapKit.h&gt;
  
  @interface MapPoint : NSObject &lt;MKAnnotation&gt;
  {
  NSString *_address;
  CLLocationCoordinate2D _coordinate;
  NSNumber *_identifier;
  }
  
  - (id)initWithAddress:(NSString*)address
      coordinate:(CLLocationCoordinate2D)coordinate
           title:(NSString *)t
      identifier:(NSNumber *)ident;
  
  
  //This is a required property from MKAnnotation
  @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
  
  //This is an optional property from MKAnnotataion
  @property (nonatomic, copy) NSString *title;
  @property (nonatomic, readonly, copy) NSString *subtitle;
  @property (nonatomic) BOOL animatesDrop;
  @property (nonatomic) BOOL canShowCallout;
  
  @property (copy) NSString *address;
  @property (copy, nonatomic) NSNumber *identifier;
  
  @end
  
  #import "MapPoint.h"
  
  @implementation MapPoint
  
  @synthesize title, subtitle, animatesDrop, canShowCallout;
  @synthesize address = _address, coordinate = _coordinate, identifier = _identifier;
  
  -(id)initWithAddress:(NSString *)address
     coordinate:(CLLocationCoordinate2D)coordinate
          title:(NSString *)t
     identifier:(NSNumber *)ident
  {
  self = [super init];
  
  if (self) {
      _address = [address copy];
      _coordinate = coordinate;
      _identifier = ident;
  
      [self setTitle:t];
  
      NSDate *theDate = [NSDate date];
  
      subtitle = [NSDateFormatter localizedStringFromDate:theDate
                                                dateStyle:NSDateFormatterMediumStyle
                                                timeStyle:NSDateFormatterMediumStyle];
      }
  return self;
  }
  
  
  @end
  </code></pre>