                 case .delete:
                     let pinCoordinate = anObject as! Pin
                     let coordinate = CLLocationCoordinate2D(latitude: pinCoordinate.latitude, longitude: pinCoordinate.longitude)
-                    //self.mapView.removeAnnotation(annotation)
                 default:
                     break
             }

    
    @IBAction func editPressed(_ sender: Any) {
        
        if (UIDevice.current.orientation != UIDeviceOrientation.landscapeLeft) &&
            (UIDevice.current.orientation != UIDeviceOrientation.landscapeRight) {
            
            if !isDeletePin{
                UIView.animate(withDuration: 0.2, animations: {
                    self.mapView.frame.origin.y -= self.editLabel.frame.height
                    self.editLabel.frame.origin.y -= self.editLabel.frame.height
                    self.isDeletePin = true
                    self.editButton.title = "Done"
                })
            }else{
                UIView.animate(withDuration: 0.2, animations: {
                    self.mapView.frame.origin.y += self.editLabel.frame.height
                    self.editLabel.frame.origin.y += self.editLabel.frame.height
                    self.isDeletePin = false
                    self.editButton.title = "Edit"
                })
            }
        }
    }
    
    }

//MARK: TravelLocationsViewController: (MKMapViewDelegate)


    func handleLongPress(_ gestureReconizer: UILongPressGestureRecognizer) {
        
        if !isDeletePin{
            // coordinates of a point the user touched on the map
            let location = gestureReconizer.location(in: self.mapView)
            let coordinate = mapView.convert(location, toCoordinateFrom: mapView)
            
            switch gestureReconizer.state {
                case .began:
                    // create a pin
                    self.droppedPin = Pin(latitude: coordinate.latitude, longitude: coordinate.longitude, context: (fetchedResultsController?.managedObjectContext)!)
                    self.delegate.stack.save()
                /* case .ended:
                    // prefetch images
                   FlickrClient.sharedInstance().getPhotosByLocation(latitude: (self.droppedPin?.latitude)!, longitude: (self.droppedPin?.longitude)!, completionHandlerForGetPhotosByLocation: { (result, error) in
                        
                        if let error = error{
                            print("Something is wrong with download: \(error.description)")
                        }else{
                            let stack = self.delegate.stack
                            
                            if (result?.count)! > 0 {
                                self.delegate.stack.performBackgroundBatchOperation({ (workerContext) in
                                    for photoFlickr in result! {
  
                                         guard let imageURLString = photoFlickr[FlickrClient.FlickrResponseKeys.MediumURL] as? String else {
                                         return
                                         }
                                         
                                         
                                         FlickrClient.downloadImage(imagePath: imageURLString) { (data, error) in
                                            if let error = error{
                                                print("Something is wrong with download: \(error.description)")
                                            }else{
                                                print("descago Imagen")
                                                let imageWithPlaceHolder = Photo(photoData: data as NSData?, photoUrl: imageURLString, context: stack.context)
                                                imageWithPlaceHolder.pin = self.droppedPin
                                         
                                                //photo.photoData = data as NSData?
                                            }
                                         }
                                    }
                                })
                            }
                        }
                    })*/

                default:
                    return
                
            }

            
            
            
            /*
            if gestureReconizer.state != UIGestureRecognizerState.ended {
                return
            }
        
            print("gestureReconizer state: \(gestureReconizer.state)")
            let location = gestureReconizer.location(in: self.mapView)
            let coordinate = mapView.convert(location, toCoordinateFrom: mapView)
        
            let _ = Pin(latitude: coordinate.latitude, longitude: coordinate.longitude, context: (fetchedResultsController?.managedObjectContext)!)
            self.delegate.stack.save()*/

        }
    }
}
