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

  • Home
  • SEARCH
  • 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 7873341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:29:03+00:00 2026-06-03T02:29:03+00:00

Currently having a slight issue. Basically my appdelegate is loading my mainViewController: self.viewController =

  • 0

Currently having a slight issue.

Basically my appdelegate is loading my mainViewController:

self.viewController = [[MainViewController alloc] initWithNibName:@"mainViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;

Now when the mainViewController loads, I want to check whether or not the user has logged in already:

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    NSInteger myInt = [prefs integerForKey:@"user"];
    if(!myInt)
    {
        self.loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
        self.loginViewController.delegate = self;
        self.loginViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self presentModalViewController:self.loginViewController animated:YES];
    }
}

It successfully checks whether or not the user is logged in, and goes into the if statement if they are not logged in. However, after running it, the eventual view that loads is the mainViewController, not the loginViewController.

If I have a separate button to send me to the login page with this code, it works fine. Of course, that is not what I need, I need users to have to log in =p

  • 1 1 Answer
  • 0 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-06-03T02:29:04+00:00Added an answer on June 3, 2026 at 2:29 am

    Put it into -viewDidAppear:.

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

Sidebar

Related Questions

Hi All I am currently having an issue calling a WCF service from a
I am currently having an issue with BackgroundWorker running on Windows Server 2003. I
I'm currently having a self signed certificate for my HTTPS webserver. In my java
I'm currently having an issue wrapping my brain around the notion of converting my
Having a slight c# problem here. I'm currently coding a small platformer-game with Unity
I'm currently having a major issue with a python script. The script runs arbitrary
The issue I'm currently having is mapping multiple GUI fields to object properties (i.e.
having a slight issue where i am rendering a pdf (stored as a byte
I am currently having an issue running a Jessica application via VS2010 and Cassini.
I'm currently having an issue with stopping a background thread in a webachive. I

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.