Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:17+00:00 2026-05-25T12:18:17+00:00

I have come across a situation today which has me wondering about best practices.

  • 0

I have come across a situation today which has me wondering about best practices. I would greatly appreciate any comments on how you would approach this simplified example:

Let’s say we have an app that requires a login to be useful. So, we have a couple of views and corresponding view controllers: LoginView and MainView. MainView is the root view and root controller for a navigation controller. LoginView is a view which allows the user to login.

So, the first time the app is launched, LoginView should be displayed, then MainView once the login is completed. On subsequent launches, only MainView will be displayed.

One approach to this would be to handle all of this in applicationDidFinishLaunching:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UIViewController *rootController = [[MainView alloc] init];
    navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];

    if ( notLoggedIn ) {
        LoginView *vc = [[LoginView alloc] initWithNibName:@"LoginView" bundle:nil];
        [rootController presentModalViewController:vc animated:NO];
    }

    return YES;
}

It would be nice to be able to handle this in a separate, dedicated “root” view controller. This controller would be loaded by the AppDelegate, and it would in turn load whichever view controller is appropriate. Can anyone offer advice on if this would be a better approach? And if so, how to go about it?

Is there a different approach you would recommend in a situation like this?

Thanks, all.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:18:18+00:00Added an answer on May 25, 2026 at 12:18 pm

    One approach would be to have a authentication provider which is a delegate. In your model classes which your views consumes, you can set the authentication provider. The delegate is a protocol which has a signature to authenticate and determine if authenticated.

    The gui would provide the model with an authentication provider delegate which can answer whether authenticated and if not would present a modal view controller to authenticate. Different model methods would ensure authenticated (by asking the provider) and if not, would call authenticate on the providers delegate. Since the gui sets the auth provider, the model isn’t breaking encapsulation and baking in gui interactions. the model is simply calling a callback.

    That means it doesn’t matter which view you’re on and what state you’re in. As any particular view crosses the model, if you’re not authenticated you will get prompted. As another example, let’s say the auth token times out after a period of time. How do you do that if auth is baked into one specific view on startup?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across a situation (which I think is weird but is possibly
i have come across a mysql database which has dates entered in a varchar
I have come across a strange problem which I would like to get your
I have come across a situation where it would be better to represent a
I have come across an awkward situation where I would like to have a
I've recently come across a situation where I've been a bit confused about which
I have come across many articles which warn against using links to provide logout
I'm making a big C project and I have never come across a situation
I have used will_paginate in my rails application but i come across a situation
I have come across this situation. In the hash1 first column is the key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.