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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:37:08+00:00 2026-05-18T10:37:08+00:00

I’ve an iPhone application: When you open the app you see the LoginView. If

  • 0

I’ve an iPhone application:
When you open the app you see the “LoginView”. If you login into application you see a TabBarController. In the third and last tab there is “Logout” button. If you click you see the “LoginView” again. My problem is that if you login again you see the “old” tabbar and the selected tab is the third and not the one, and there is a “Logout” button. Also, if a user login with a different user, see the old data of the previous user (very dangerous).

Here’s the code:
– Delegate.h:

UITabBarController *tabBarController;
LoginViewController *loginView;

– Delegate.m (didFinishLaunchingWithOptions):

[self.window makeKeyAndVisible];

loginView = [[LoginViewController alloc] init];

if (YES) { /* if the user is not already logged */
    [self.window addSubview:loginView.view];
}

Delegate.m (methods):

- (void)loginComplete {
    [loginView dismissModalViewControllerAnimated:YES];
    [window addSubview:tabBarController.view];
}

- (void)logoutComplete {
    [[tabBarController view] removeFromSuperview];
    [tabBarController release];
    [window addSubview:loginView.view];
}

And here’s the two methods in two different viewcontrollers:

- (IBAction)login:(id)sender {

     TabNavisAppDelegate *delegate =
      (TabNavisAppDelegate *) [[UIApplication sharedApplication] delegate];
  [delegate loginComplete];
  }

(the logout method is the same)

Guys, how can I solve this painful problem?
So, here’s a list of application that do what I want: “Foursquare”, “Brightkite” and others.
Each one have a login screen, a tabbar view and a logout button.

Thanks @ everyone.

  • 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-18T10:37:08+00:00Added an answer on May 18, 2026 at 10:37 am

    For login-logout-login situations where all kinds of things need to reset themselves at the logout or the next login, I like to create a notification, something like “NewUserReset.” Everything that needs to reset itself to an original state listens for the notification and runs a method that does whatever kind of resetting it needs. The tabbar would change the button title to logout, temporary data structures nil/zero/release themselves, etc.

    It’s nicely decouples the logout from all of the things that have to be done so you’re not trying to manipulate view controllers and data storage and view appearances from the the controller that received the logout tap.

    Sending a notification is easy. When the user taps the Logout button you’ll send out a notification like this:

    [[NSNotificationCenter defaultCenter] postNotificationName:@"JMUserLogout" 
                                                    object:nil];
    

    You don’t have to call it JMUserLogout, you just need a string that you’ll recognize and something — I used your initials — to help ensure you don’t accidentally send a notification that has the same name as a notification something you’re unaware of is listening for.

    When that notification goes out, any object that has registered with the defaultCenter to listen for @”JMUserLogout” will perform any actions you choose. Here’s how your object registers (this should be located in some place like ViewWillLoad or the initialization method of the object):

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(resetForNewUser:)
                                             name:@"JMUserLogout"
                                           object:nil];
    

    The selector there, resetForNewUser:, is just the name of a method you want to run when the notification goes out. That method looks like this:

    - (void)resetForNewUser:(NSNotification *)notif {
        // DO SOMETHING HERE
    }
    

    Where it says // DO SOMETHING HERE you’ll add the code specific to your app. For example, you can add the tab bar as an observer of the JMUserLogout notification. In its resetForNewUser: method you’d change the name of the logout button to Login.

    In a ViewController or View or data store that holds old data from the previous user the resetForNewUser method would delete all of that data and set things back to the way they should be fore a new user. For example, if the previous user entered data into a UITextField you would delete the text, yourTextFieldName.text = @””;

    Lastly, it’s important that you also remove your object as an observer before it’s deallocated. In your Dealloc method of each object that registered to receive the notification you add this:

    [[NSNotificationCenter defaultCenter] removeObserver:self];
    

    Hopefully that makes sense. The Apple documentation for NSNotificationCenter explains more and they provide several sample apps that use notifications.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.