ios - What would cause my segue to infinitely loop? -


i've implemented count-down timer automatically start application if user doesn't select options. when timer hits zero, invalidate , fire performseguewithidentifier, segues me desired view.

at point fine... well, sort of. notice view fires twice, fine after that. @ point, if navigate away view, again, segue fires , view loads on , on until stop app.

my output window shows:

2015-05-13 21:20:26.880 web app browser[43407:7957566] unbalanced calls begin/end appearance transitions . 2015-05-13 21:20:28.825 web app browser[43407:7957566] unbalanced calls begin/end appearance transitions .

here's view controller:

class startviewcontroller: uiviewcontroller {      var countdown = bool()     var timer = nstimer()     var count = 5     @iboutlet weak var countdownlabel: uilabel!      override func viewdidload() {         super.viewdidload()          countdown = appdelegate().userdefaults.valueforkey("auto start") as! bool          if countdown == true {             var timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector: selector("update"), userinfo: nil, repeats: true)          } else {             countdownlabel.text = ""         }           }      func update() {         countdownlabel.text = "\(count)"          if count == 0 {             timer.invalidate()             self.performseguewithidentifier("toweb", sender: nil)         } else {             count--         }     } } 

my storyboard:

in image below, see selected segue, takes user start screen navigation controller has embedded viewcontroller. you'll note i've added identifier "toweb".

enter image description here

my question:

what cause segue infinitely loop?

not sure if directly related issue, declaring timer twice, once locally , once @ class scope.

var countdown = bool() var timer = nstimer() var count = 5 @iboutlet weak var countdownlabel: uilabel!  override func viewdidload() {     super.viewdidload()      countdown = appdelegate().userdefaults.valueforkey("auto start") as! bool      if countdown == true {         var timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector: selector("update"), userinfo: nil, repeats: true)      } else {         countdownlabel.text = ""     }       } 

you see var timer = nstimer() creates timer @ class scope

var timer = nstimer.scheduletimerwithtimeinterval... creates new timer in scope of viewdidload. assume should timer = nstimer.scheduletimer...


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -