Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //contador para pines junto con su timer
- var pinCounter = 0
- var pinLimit = 5
- var seconds = 0
- var limitTime = 86400
- var timer = Timer()
- @objc func timerAction() {
- seconds += 1
- if(seconds >= limitTime){
- pinCounter = 0
- timer.invalidate()
- }
- }
- @IBAction func subirAlerta(_ sender: Any) {
- 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{
- //start timer
- //timer.invalidate()
- timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.timerAction), userInfo: nil, repeats: true)
- 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