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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:42:06+00:00 2026-05-27T03:42:06+00:00

I have set my app’s initial view with storyboard to the main one. I

  • 0

I have set my app’s initial view with storyboard to the main one. I have this code in the app delegate that should load the login VC if the user is not signed in already:

if (currentUser) {
    // do stuff with the user
    //use storybaord nibs
} else {
    // show the signup or login screen
    UIStoryboard *storyboard = self.window.rootViewController.storyboard;
    self.window.rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginVC"];
}

The problem is I don’t have the logic for currentUser. That is just suedo code. How can I set this up properly?

This is the code I use in the actual login VC to log a user in. I save username/pass to NSUserDefaults.

-(IBAction)loginButtonPressed:(id)sender{
    ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://myapp.com/20111115/60b88126/login_user/"]]];
    [request setPostValue:self.usernameTextField.text forKey:@"username"];
    [request setPostValue:self.passwordTextField.text forKey:@"password"];
    [request startSynchronous];

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];   
    [userDefaults setObject:self.usernameTextField.text forKey:@"login"];
    [userDefaults setObject:self.passwordTextField.text forKey:@"password"];

    NSError *error = [request error];
    NSString *responseString = nil;
    if (!error) {
        responseString = [request responseString];
    } else {
        responseString = @"Failed to connect to server, please check your WiFi or 3G connection.";
    }
    NSDictionary *responseDictionary = [responseString JSONValue];
    NSString *loginProblems = [responseDictionary valueForKey:@"login_errors"];
    if (![loginProblems isEqualToString:@""]) {
        //Invalid login
    } else {
        [self performSegueWithIdentifier:@"login" sender:self];
    }
}
  • 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-27T03:42:07+00:00Added an answer on May 27, 2026 at 3:42 am

    can you just check to see if the NSUserDefaults have values for the username/password and proceed from there? you would just need to make sure to clear those values when he logs out.

    So if the username/password field for NSUserDefaults is empty, send him to the login. if it has values, “do stuff”. when he logs out, clear the values?

    or make an instant variable in the AppDelegate stating he is logged in or not?

    create the variable in the app delegate just like normal a normal instance variable then use:

        InspectAppDelegate *dataCenter = (InspectAppDelegate *) [[UIApplication sharedApplication] delegate];
    

    to access it in a different view controller (need to declare it in any method you use it in).

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

Sidebar

Related Questions

I have set up some gesture recognition in an app that I'm building. One
The way I have my app set up now the initial activity that launches
I have set up an app that is registered for remote notifications. - (void)application:(UIApplication*)application
I have an app with four activities. I have set the intent-filter on one
I have set my iPad app to Landscape mode using following code.. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
In my app I have set the storyboard to allow only horizontal and inverted
I have set up the code to call a remote server from Android app
I believe I have set up our MVC app to use [HandleError] properly. This
I have set my compression like this for my NSMutableUrlRequest on my iphone app
I have one app in which i called the webservice and set the data

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.