Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
There's an error
When I run my app with not logged in user performs "showLogin" seque and I see LoginViewController. If i would try to swipe from left side to right (it is the same as back button in NavigationController) navigation controller would try to pop the previous view controller and then error happens. Error without description. I can't understand why it happens. It seems to me that the InboxViewController should appear.
It's been a while since I did this course, so I don't remember how the login screen segue was implemented. But it would seem that you shouldn't be able to go to the inbox at all if not logged in. If your navigation controller is trying to pop the login screen without being logged in, then something is wrong.
Login screen isn't modal. There's a push-segue. The previous course where I build Ribbit app was upon iOs 6. There was no such gesture (swipe for pop previous view controller). So we just hided back button. There's an logical problem. I think we must check logged in user or not in AppDelegate instead of ViewController. But there's another question. Why app crashes when trying to display InboxViewController with not logged in user.
I've found out what is the error. I have checking for logged in user in viewDidLoad method of InboxViewController. I must replace it to the viewWillAppear
In the viewDidAppear of InboxViewController we try to perform PFQuery using currentUser which is null. So app crashes.
Ok... if the user is not supposed to be able to "go back" from the login view without login in, then that view really should be presented modally. There are a couple of ways you can prevent the navigation controller from responding to the swipe, but the implementation changes between versions of iOS, and apparently doing so is cause for rejection at the app store.
So - present the view modally :)
Thank you, Rasmus!