Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. //contador para pines por dia, guarda la variable oldPinDate e preferencias
  2.  
  3. var pinCounter = 0
  4. var pinLimit = 5
  5.  
  6. var date: Date
  7. var formatter: DateFormatter
  8.  
  9. var oldPinDate: String
  10. var currentDate: String
  11.  
  12. @IBAction func subirAlerta(_ sender: Any) {
  13. formatter.dateFormat = "dd.MM.yyyy"
  14. currentDate = formatter.string(from: date)
  15. if(currentDate != oldPinDate){
  16. pinCounter = 0
  17. }
  18. pinCounter += 1
  19. if(pinCounter < pinLimit){
  20. uploadPin(title: "Alerta", subtitle: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, lon: (gps.location?.coordinate.longitude)!)
  21. btPin(titulo: "Alerta", subtitulo: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, long: (gps.location?.coordinate.longitude)!)
  22. }else{
  23. oldPinDate = formatter.string(from: date)
  24. //guardar fecha en preferencias
  25. let alert = UIAlertController(title: "Alert", message: "Ya subiste suficientes pines", preferredStyle: UIAlertControllerStyle.alert)
  26. alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil))
  27. self.present(alert, animated: true, completion: nil)
  28. }
  29. menuPinIsShown = false;
  30. ponerPin.isHidden = true;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement