Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //contador para pines por dia, guarda la variable oldPinDate e preferencias
- var pinCounter = 0
- var pinLimit = 5
- var date: Date
- var formatter: DateFormatter
- var oldPinDate: String
- var currentDate: String
- @IBAction func subirAlerta(_ sender: Any) {
- formatter.dateFormat = "dd.MM.yyyy"
- currentDate = formatter.string(from: date)
- if(currentDate != oldPinDate){
- pinCounter = 0
- }
- pinCounter += 1
- if(pinCounter < pinLimit){
- uploadPin(title: "Alerta", subtitle: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, lon: (gps.location?.coordinate.longitude)!)
- btPin(titulo: "Alerta", subtitulo: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, long: (gps.location?.coordinate.longitude)!)
- }else{
- oldPinDate = formatter.string(from: date)
- //guardar fecha en preferencias
- let alert = UIAlertController(title: "Alert", message: "Ya subiste suficientes pines", preferredStyle: UIAlertControllerStyle.alert)
- alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil))
- self.present(alert, animated: true, completion: nil)
- }
- menuPinIsShown = false;
- ponerPin.isHidden = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement