I encountered a problem while testing my app. You can see how I have setup my views in the following image:
The thing is that everything works fine. I user my test user to login, and the following code executes the loginSegue,
self.performSegueWithIdentifier("loginSegue", sender: self)
which is a modal segue that links my login "View Controller" with the "Home Tab Bar View Controller". I get redirected to the "Initial Feed View Controller". Everything works great. But when I go to my "Settings View Controller", and click on the Logout button, which has the following code (IBAction):
@IBAction func logoutAction(sender: AnyObject) {
PFUser.logOut()
self.performSegueWithIdentifier("logoutSegue", sender: self)
}
my app crashes. My Logout button's action has a segue that takes you back to the login "View Controller", but logs the user out first (I am using Parse by the way). This "Push" segue is called logoutSegue. I tried to change the segue to be a "Popover" segue. That solves the issue, kinda, since by doing so it messes up my "Registration View Controller" since when in the login "View Controller" I click on the button "Register" and the app crashes anyways.
The compiler tells me that the following line of code is the one causing the error:
self.performSegueWithIdentifier("logoutSegue", sender: self)
I do not understand why this is happening. I suppose that it has something to do with how I have my "Navigation Controller" and "Home Tab Bar View Controller" setup. Or maybe with Delegates?
Could you help me to fix this? It does not matter if you have an Objective-C approach, please feel free to suggest a solution and I can try to convert it from Objective-C to Swift.
Besides helping me fixing my issue, I was wondering if you know what is the difference between the type of Segues (Push, Modal, Popover, Replace) and when should I use each. I read Apple's documentation but I still don't understand it in its' entirety.
Thank you in advance for your advice and responses.