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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:47:10+00:00 2026-05-25T14:47:10+00:00

I am relatively new to iPhone development so please excuse what I hope is

  • 0

I am relatively new to iPhone development so please excuse what I hope is an easy task/question.

I have an app with a tab bar with several views each controlled by a MVC group. On loading the app the first mvc group of the tabbar gets displayed. In the viewDidAppear method of this first view controller I have a login screen modally displayed like so:

- (void ) viewWillAppear:(BOOL)animated
{
    LoginViewController *loginvc = [[LoginViewController alloc] init];
    loginvc.delegate = self;
    if (*xxxxx*) {
        [loginvc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
        [self presentModalViewController:loginvc animated:NO];  
    }
    [loginvc release];
}

For the conditional if statement I would like a method to be called which checks that the user is logged in. I have provisionally (just for testing purposes) placed this method in the loginvc view controller however this cannot be a long term solution as the loginvc gets dealloc-ed once its dismissed (its the modal view).

At the moment I have a class set up like the following but don’t know if this is correct, and don’t know where to instantiate it (should this be in my main app delegate method application:didFinishLaunchingWithOptions: ?), and don’t know how to change the userIsLoggedIn variable:

LoginClass.h file

#import <Foundation/Foundation.h>

@interface LoginClass : NSObject {
    BOOL userIsLoggedIn;
}

-(BOOL)checkIfUserIsLoggedIn;

@end

LoginClass.m file

#import "LoginClass.h"

@implementation LoginClass

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
        userIsLoggedIn = NO;
    }

    return self;
}

-(BOOL)checkIfUserIsLoggedIn
{
    return userIsLoggedIn;
}

@end

My question is how should I create an object of this class which exists for the whole time the application is alive. This is so that when the app is launched, the login screen is displayed, but after successful login the ‘userIsLoggedIn’ variable gets set to ‘YES’ so that if the first mvc is called again the login screen doesn’t get displayed modally again.

I hope I have made sense and hope someone can help with the code. If I am approaching this wrong please let me know alternative strategies (for example should I even be calling the modal display from the viewDidAppear of the first mvc?).

Thanks in advance,
Andy

  • 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-25T14:47:11+00:00Added an answer on May 25, 2026 at 2:47 pm

    The App Delegate is the place where your Login class should be. It’s always reachable by your view controllers and “lives” for the whole time your app is running. Check the docs to see how to access your App Delegate from your view controllers.

    Your Login Class should also look like this:

    #import <Foundation/Foundation.h>
    
    @interface LoginClass : NSObject {
        BOOL userIsLoggedIn;
    }
    @property (nonatomic) BOOL userIsLoggedIn;
    
    -(BOOL)checkIfUserIsLoggedIn;
    
    @end
    
    
    // Implemenatation
    #import "LoginClass.h"
    
    @implementation LoginClass
    @synthesize userIsLoggedIn;
    - (id)init
    {
        self = [super init];
        if (self) {
            // Initialization code here.
            userIsLoggedIn = NO;
        }
    
        return self;
    }
    
    -(BOOL)checkIfUserIsLoggedIn
    {
        return userIsLoggedIn;
    }
    
    @end
    

    To set the login state, simply do something like this:

    [[yourAppDelegateVar instanceOfLoginClass] setUserIsLoggedIn:YES];
    

    or

    [[yourAppDelegateVar instanceOfLoginClass] setUserIsLoggedIn:NO];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a new iPhone app and am relatively new to Cocoa development overall.
I have done some iPhone application development but still am relatively new at it.
I am relatively new to iPhone programming, and I have a considerably complex app
I am relatively new to Objective C/iPhone Development. I am developing a simple app
I am relatively new to iPhone development ,i tried to add uitableview to scroll
I'm relatively new to iPhone Development, so this may be my fault, but it
I'm relatively new to iPhone programming but have read my way through a hefty
I am relatively new to IPhone coding, although I have reached the point of
I'm relatively new to objective-c...I'm using the iphone 3.0 SDK I have a UIView,
Hello I am new to iPhone development and I am making an app which

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.