0

Within the else part of a else if statement I would like the view controller to automatically switch to another view controller lets say "b". So this below is what I'm looking for.

if {
    stop.timer
} else {
    switch to b
}

what is the code to switch to b?

Thanks

Arasuvel
  • 2,953
  • 1
  • 28
  • 40
  • Are you asking for a way to programmatically present new vc? – Tj3n Dec 26 '16 at 03:56
  • @Tj3n yes that is what I am trying to do. –  Dec 26 '16 at 04:01
  • This has been asked many times, do a google search first before create new question – Tj3n Dec 26 '16 at 04:11
  • Possible duplicate of [How to move data from one view controller to another in Swift?](http://stackoverflow.com/questions/29309329/how-to-move-data-from-one-view-controller-to-another-in-swift) – Himanshu Moradiya Dec 26 '16 at 04:17

2 Answers2

0

In your else statement

let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("view") as! ViewController
self.navigationController?.pushViewController(nextViewController, animated:true)
Waqar Khalid
  • 119
  • 1
  • 12
0

open your main.storyboard and provide the storyboard identifier(any name) for your viewcontroller in StoryboardID enter image description here

in your code .

if you want to Push

if {
    stop.timer
} else {
   let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("VerifyUserVC") as! VerifyUserVC
self.navigationController?.pushViewController(nextViewController, animated:true)
}

and if you want to present Modally

if {
        stop.timer
    } else {
       let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("VerifyUserVC") as! VerifyUserVC
    self.presentViewController(nextViewController, animated: true, completion: nil)
    }
Jagdeep
  • 1,148
  • 11
  • 16