title: Swift: MapKit - Recognize Pin Tap
body: <p>I must be missing something obvious here.....</p>
  
  <p>Works: 
  Add a bunch of MKPointAnnotations from Core Data...shows on Map</p>
  
  <p>Does Not Work: 
  Try to have a print statement appear when a pin is tapped. </p>
  
  <p>I have the MKMapView Delegate set and did not implement AnnotationView since I wish to segue immediately after a pin is tapped. Would rather not show a context dialog.</p>
  
  <p>What am I missing to recognize a pin is tapped?</p>
  
  <pre><code>import UIKit
  import MapKit
  import Foundation
  import CoreData
  
  class MapViewController: UIViewController, MKMapViewDelegate {    
      @IBOutlet weak var mapOutlet: MKMapView!
  
      var latitude = 100.0 as Double
      var longitude = 120.0 as Double
  
      var pins = [NSManagedObject]()
  
      func pullPins()    {
          let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
          let managedContext = appDelegate.managedObjectContext
  
          let fetchRequest = NSFetchRequest(entityName: "Pin")
  
          do {
              let results = try managedContext.executeFetchRequest(fetchRequest)
              pins = results as! [NSManagedObject]
  
              for pin in pins {
                  let pinLat = pin.valueForKey("latitude") as! Double
                  let pinLon = pin.valueForKey("longitude") as! Double
  
                  let pinCoordinate = CLLocationCoordinate2D(latitude: pinLat, longitude: pinLon)
  
                  let annotation = MKPointAnnotation()
                  annotation.coordinate = pinCoordinate
  
                  self.mapOutlet.addAnnotation(annotation)
              }
          }
          catch let error as NSError {
              print("Could not fetch \(error), \(error.userInfo)")
          }
      }
  
  
      func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
          print("Pin Tapped")
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          pullPins()
      }
  }
  </code></pre>