1
func checkForRecipes(noRecords: Bool) {

    //segue to addNewRecipe page

    if noRecords == true{

        print("Can't Find any Recipes!")

        self.performSegue(withIdentifier: "ToAddNewRecipeVC", sender: self)

    }else{

        print("error, noRecords not equal to zero")
    }

I am able to segue successfully via the storyboard but want to do so programmatically based on information returned from a delegate.

Upon running the app, the information from the delegate is successfully sent to the function "checkForRecipes" -i.e "noRecords" returns TRUE, but for some reason, the below line of code within that function does not seem to execute (and no errors are thrown):

self.performSegue(withIdentifier: "ToAddNewRecipeVC", sender: self)

The app starts up but stops at the main screen, whereas it should segue to the "AddNewRecipe" view controller.

The segue itself definitely has a segue ID of "ToAddNewRecipeVC". I have also tried dispatching to the main queue (to no avail) based on the following thread.

I'm stumped - what's going wrong here?

Community
  • 1
  • 1
Rossco
  • 37
  • 5
  • Using screenshot's for code is frowned upon. Place your code in the question. – MwcsMac Oct 12 '16 at 19:51
  • @MwcsMac: I have replaced the screenshot with a clip of code. – Rossco Oct 12 '16 at 19:58
  • where checkForRecipes() is called ? – nsinvocation Oct 12 '16 at 20:02
  • check if everything is set up right. You can use my answer here http://stackoverflow.com/a/39930180/5327882 to a quite similar issue. In the end it was just a wrong view controller which was set up in the code – ronatory Oct 12 '16 at 20:05
  • @Azimov: "noRecords" is sent to checkForRecipes() from another class via the delegate pattern. – Rossco Oct 12 '16 at 20:07
  • @ronatory: Thanks for the link - it looks as though I should be good - segue ID set, each of the two view controllers have their own custom class set and both view controllers are indeed of type UIViewController. – Rossco Oct 12 '16 at 20:32

1 Answers1

1

OK, it looks as though I have solved the problem. I embedded the main view controller into a navigation controller and now everything works as intended. I tried this same tactic earlier and it kept throwing up errors. grrr!

Anyway - thank you to all for the input!

Rossco
  • 37
  • 5