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 6119885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:36:17+00:00 2026-05-23T15:36:17+00:00

I’m new to programming and I have the following problem I was hoping someone

  • 0

I’m new to programming and I have the following problem I was hoping someone could help with. I have an app that uses a loggin to access the main menu. I would like the app to store the users name (from the login screen) and use it within the program. If the user has already logged in they don’t have to log in again, ever. I want the app to check if the user has logged in on start up and go directly to the menu menu if they have.

My problem is at present if they press the login button they go straight to main menu without entering login details. If they enter they name I can use their name within the app until the app is restarted and the info is gone.

OK here is my new code but I still have the same problem.

-(IBAction)LogInButton:(id)sender {

    NSString *tempstr = [[NSUserDefaults standardUserDefaults]      objectForKey:@"username"];

    if (tempstr.length == 0) {
        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        [prefs setObject:name.text forKey:@"username"];
        [prefs synchronize];
        [self showCorrectController];

        ClubFindViewController *logView = [[ClubFindViewController alloc]     initWithNibName:@"ClubFindViewController" bundle:nil];
        [self presentModalViewController:logView animated:YES];
    }
    else {
        MainMenuView *mainView = [[MainMenuView alloc]     initWithNibName:@"MainMenuView" bundle:nil];
        [self presentModalViewController:mainView animated:YES];
    }
}

-(void)viewDidLoad {
    [super viewDidLoad];
    [self showCorrectController];
}

-(void)showCorrectController {
    UIViewController *viewController = nil;

    if ([self isLoggedIn]) {
        viewController = [[MainMenuView alloc] init];
    }
    else {
        viewController = [[ClubFindViewController alloc] init];
    }

    [self presentModalViewController:viewController animated:YES];
    [viewController release];
     viewController = nil;
}

-(BOOL)isLoggedIn {
    return ![[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
}

Any help would be greatly appriecated. Thanks.

  • 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-05-23T15:36:17+00:00Added an answer on May 23, 2026 at 3:36 pm

    In -(IBAction)LogInButton:(id)sender { You should check if they have entered text, If not, prompt again.
    In your case if the user presses ‘Login’ without entering name, the ‘username’ value will have empty string and the login will go through.

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

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have been unable to fix a problem with Java Unicode and encoding. The
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't

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.