title: MapKit annotations inconsistently deleting, don't know why
body: <p>I am making a basic dummy app for myself because I am just starting with xcode and swift 3. 
  clearLastPin function should remove the most recent pin placed. Sometimes it does but more often than not it does not.
  I'm not sure where there is such inconsistency, and the same goes for clearPins, which should remove ever pin from map.</p>
  
  <pre><code>@IBAction func clearLastPin(_ sender: UIBarButtonItem) {
      newAnnotationCount = self.mapView.annotations.count - 1
      //prints for testing
      print("pressed")
      print("new",newAnnotationCount)
      print("mapView",self.mapView.annotations.count)
      if newAnnotationCount != 0{
          print("if statement entered")
          annotation = self.mapView.annotations[self.mapView.annotations.count - 1]
          self.mapView.removeAnnotation(annotation)
      }
  }
  
  @IBAction func clearPins(_ sender: UIBarButtonItem) {
      newAnnotationCount = self.mapView.annotations.count - 1
      print("pressed")
      while newAnnotationCount != 0{
          print("while statement entered")
          annotation = self.mapView.annotations[self.mapView.annotations.count - 1]
          self.mapView.removeAnnotation(annotation)
          newAnnotationCount = newAnnotationCount - 1
      }
  }
  
  func searchBarSearchButtonClicked(_ searchBar: UISearchBar){
      //1
      searchBar.resignFirstResponder()
      dismiss(animated: true, completion: nil) //the app will dismiss the presented search controller
      //map view will look for any previously drawn annotation on the map and remove it
  
  
      //2
      //the ‘naturalLanguageQuery’ is very important in order to look up for -even an incomplete- addresses and POI (point of interests) like
      //restaurants, Coffeehouse, etc.
      localSearchRequest = MKLocalSearchRequest()
      localSearchRequest.naturalLanguageQuery = searchBar.text //transforming the search bar text into a natural language query
      localSearch = MKLocalSearch(request: localSearchRequest)
      localSearch.start { (localSearchResponse, error) -&gt; Void in
  
          if localSearchResponse == nil{
              let alertController = UIAlertController(title: nil, message: "Place Not Found", preferredStyle: UIAlertControllerStyle.alert)
              alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default, handler: nil))
              self.present(alertController, animated: true, completion: nil)
              return
          }
          //3
          //If the search API returns a valid coordinates for the place, then the app will instantiate a 2D point and draw it on the map within 
          //a pin annotation view
          self.pointAnnotation = MKPointAnnotation()
          self.pointAnnotation.title = searchBar.text
          self.pointAnnotation.coordinate = CLLocationCoordinate2D(latitude: localSearchResponse!.boundingRegion.center.latitude, longitude:     localSearchResponse!.boundingRegion.center.longitude)
  
  
          self.pinAnnotationView = MKPinAnnotationView(annotation: self.pointAnnotation, reuseIdentifier: nil)
          self.mapView.centerCoordinate = self.pointAnnotation.coordinate
          self.mapView.addAnnotation(self.pinAnnotationView.annotation!)
  
          //: zooms in on coordinate of found location
          /*
          let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01) // how far zoomed in
          let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(localSearchResponse!.boundingRegion.center.latitude, localSearchResponse!.boundingRegion.center.longitude) // users location
          let region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span) // links the two, I guess
  
          self.mapView.setRegion(region, animated: true) // maps region is equal to region we just made
          */
  
      }
  }
  </code></pre>