Advertisement
Guest User

omaewa

a guest
Nov 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. //contador para pines junto con su timer
  2.  
  3. var pinCounter = 0
  4. var pinLimit = 5
  5.  
  6. var seconds = 0
  7. var limitTime = 86400
  8.  
  9. var timer = Timer()
  10.  
  11. @objc func timerAction() {
  12. seconds += 1
  13. if(seconds >= limitTime){
  14. pinCounter = 0
  15. timer.invalidate()
  16. }
  17. }
  18.  
  19. @IBAction func subirAlerta(_ sender: Any) {
  20. pinCounter += 1
  21. if(pinCounter < pinLimit){
  22. uploadPin(title: "Alerta", subtitle: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, lon: (gps.location?.coordinate.longitude)!)
  23. btPin(titulo: "Alerta", subtitulo: subtitulo.text!, lat: (gps.location?.coordinate.latitude)!, long: (gps.location?.coordinate.longitude)!)
  24. }else{
  25. //start timer
  26. //timer.invalidate()
  27. timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.timerAction), userInfo: nil, repeats: true)
  28. let alert = UIAlertController(title: "Alert", message: "Ya subiste suficientes pines", preferredStyle: UIAlertControllerStyle.alert)
  29. alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil))
  30. self.present(alert, animated: true, completion: nil)
  31. }
  32. menuPinIsShown = false;
  33. ponerPin.isHidden = true;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement