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! While you're at it, check out some resources Treehouse students have shared here.

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

iOS

Lachlan Mitchell
Lachlan Mitchell
9,278 Points

Creating a Better Sign-Up Flow

Hey everyone! Firstly, I want to thank all the staff at Team Treehouse. The iOS courses taught by Amit and Ben have given me the confidence and knowledge to start creating my own apps, and I can't wait for your future courses on the topic.

Specifically, I'm very interested in apps that have a heavy social aspect. A great example is Ribbit, where the user creates an account on Parse, logs in, and is then able to select friends and share content with them. What's bugging me is the sign-up flow for Ribbit. I'm not an expert by any definition of the word, but I just had a few queries as to how it works in regard to memory management...

When the app opens, LoginViewController is pushed onto the stack if a user isn't currently logged in. After they either log in or sign up through SignupViewController*, those controllers are popped until the root controller is reached, **InboxViewController. When they log out, the cached PFUser is cleared and LoginViewController is pushed back onto the stack.

To me, this feels like a bit of a 'workaround' solution. Wouldn't it be better to somehow set LoginViewContoller as the root and push (or modally present) the rest of the app on top of it? That way, when the user logs out, all child view controllers (The TabBarController and all its children) are cleared from memory. That means that when another user logs in, the controllers are presented fresh for them, with none of the previous users data still present or needing to be cleared manually. In this way, the TabBar and NavigationBar don't need to be hidden manually because they aren't embedded yet.

I have tried to implement this myself, but I can't figure out a way to do it. Am I on the right track, or is the way Ribbit implemented the sign up flow a better solution?

Any discussion on the subject would be greatly appreciated! Thanks!

4 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Mobile devices are very personal devices. So the UX is always geared towards getting to the screen that matters most to the user. The assumption is that the login/sign-up screen will only be displayed once and never again. When the user comes back to the app you want to bring them directly to the Inbox without requiring them to login over and over again.

Lachlan Mitchell
Lachlan Mitchell
9,278 Points

Sorry Amit, I may not have explained myself properly.

The user should of course only have to log in once. I just meant that it might be a good idea to have LoginViewController set as the root view controller of the app. Thus, the rest of the app is presented as a child of LoginViewController, allowing all data to be cleared simply by deallocating the TabBarController on logout. It just seems to me like a better workflow, though I'm asking for your opinion and guidance :)

In short: On Login -> TabBar presented (The main app), On Signup -> TabBar presented (The main app), On Logout -> Dismiss TabBar (and therefore the entire app) and return to LoginViewController.

On all subsequent app loads, either LoginViewController or TabBar will be presented depending on whether or not a user is already logged in.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

I understand what you are getting at but if the LoginViewController should only be loaded once then it makes no sense to make everything a child controller of it. The entire premise of a modal view controller is to disrupt the normal UX of your application. That said if you still want to do it this way then I would use a delegate. I would create a TabBarControllerDelegate that has a logout method and have the LoginViewController implement it and then call the logout method from your TabBarController. Or you can use notifications.

Stone Preston
Stone Preston
42,016 Points

when you say you couldnt get it to work, what did you try. It seems like all you would have to do would be to set the login view controller as the initial view controller and change some segues around and some code in your inbox view controller (when logout is pressed, segue to the login view controller instead of popping etc)

Lachlan Mitchell
Lachlan Mitchell
9,278 Points

([LoginViewController] -> [SignupViewController]) (modal segue from either)-> [TabBarController]

The TabBarController first presents [InboxViewController] which has a logout button to get back to [LoginViewController]. That won't work however as it could have been modally presented by either login OR signup. If you dismissModalViewController:animated:, it doesn't work like it does in Ribbit. Naturally, I could be missing some key piece of knowledge here. It just made sense to me that the app should sit onto of the login screen rather than the other way around.

(Sorry, I meant to respond to you Stone.)