0

I'm making an ios app and I want the user to be presented with a different page on load if they have selected an option.

 override func viewDidLoad() {
    super.viewDidLoad()
    if UserDefaults.standard.object(forKey: "setting") == nil{
        //dostuff
    }
    else {
        goToNextPage()
    }

This does not work. But when I put a timer to keep trying every 0.5 seconds it works. What am I missing here? What's going on behind the scenes that won't allow my segue to be called?

Thanks for any help :)

John Smith
  • 11
  • 3
  • See: https://stackoverflow.com/questions/45653825/perform-segue-in-viewdidload – dan Jun 03 '18 at 03:52
  • If you have more than 1 view controller as initial view controller, then this isn't the best practice. You should load storyboard programmatically. – Lal Krishna Jun 03 '18 at 04:02

0 Answers0