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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:15:35+00:00 2026-06-04T23:15:35+00:00

I know the title may sound a little weird, but the same goes for

  • 0

I know the title may sound a little weird, but the same goes for the problem.

I’ve been testing my app on the simulator almost the entire time in development, I did test it once in a while on a real device just to make sure.
But now that I’m close to finishing a problem came up.

Whenever I preform a login, my entire app crashes saying the username and password variables are deallocated …

Here’s the flow of my application:

When opening the app, it checks if the username and password was saved or note

- (void)checkIfPreviouslyLoggedIn:(BOOL)didLogin andLogin:(BOOL)doLogin {
     // some logic to get it out of the keychain
     NSLog(@"checkIfPreviouslyLggedIn: ACCOUNT %@ / %@", tmpUsername, tmpPassword);

     // RETURN: checkIfPreviouslyLggedIn: ACCOUNT  /
}

Nothing was saved before, no big deal, the user will just input the account and press login

- (void)loginWithUsername:(NSString *)username andPassword:(NSString *)password {
      NSLog(@"loginWithUsername: ACCOUNT %@ / %@", username, password);
      // RETURN: loginWithUsername: ACCOUNT testUser / password

      // save it for later use
      _username = username;
      _password = password;

      NSLog(@"loginWithUsername: ACCOUNT %@ / %@", _username, _password);
      // RETURN: loginWithUsername: ACCOUNT testUser / password

      // Attach a notification handler
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginCheck:) name:@"LoginCheck" object:nil];

      // call the web API
      [self doRequestFromLocation:@"/groups" withPostType:@"GET" andData:nil whichTriggersNotification:@"LoginCheck"];
}

Cool, the username and password are nicely logged, so far so good, the doRequestFromLocation is basically a queue type thing, I can send as many requests as I want and it will handle them one by one

- (void)doRequestFromLocation:(NSString *)location withPostType:(NSString *)type andData:(NSData *)data whichTriggersNotification:(NSString *)notification {
      NSLog(@"doRequestFromLocation: ACCOUNT %@ / %@", _username, _password);
      // RETURN: doRequestFromLocation: ACCOUNT testUser / password
} 

It then goes to a doRequest method, which does the actual data request, again, I log my username there and it’s returning the correct one.

NSLog(@"doRequest: ACCOUNT %@ / %@", _username, _password);

It’s after this that everything goes horribly wrong, when the request is completed, loginCheck() is called

- (void)loginCheck:(NSNotification *)notification {
    NSLog(@"loginCheck: ACCOUNT %@ / %@", _username, _password);
}

In here my _username and _password are deallocated, even right before the actual call I check the username and password and they are still fine.

So somehow (magically) those 2 variables got deallocated without any reason.
Note that _username and _password is ONLY set in loginWithUsername, they don’t change anywhere in my application.

2012-06-04 13:33:28.001 coop[5060:707] * -[CFString respondsToSelector:]: message sent to deallocated instance 0x1099fc40
2012-06-04 13:33:28.648 coop[5060:707] *
-[CFString _cfTypeID]: message sent to deallocated instance 0x1099fc40

What could have caused this, I added multiple breakpoints, only to realize that somewhere between the call and the loginCheck() they disappear.

  • 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-04T23:15:37+00:00Added an answer on June 4, 2026 at 11:15 pm

    the problem is here:

     // save it for later use
          _username = username;
          _password = password;
    

    your variables _username and _password are not retained that’s why they are getting autoreleased.

    either in NON-ARC case, declare them as @property(retain) and for ARC, @property(strong) use :

    self._username = username;
    self._password = password;
    

    now you own the ownership of the memory and now you have to release it whenever you’re done.

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

Sidebar

Related Questions

Ok, the title may sound a little weird, but I think that kinda describe
The title may sound confusing but it actually isn't, I just didn't know how
The title may be a little confusing, but I don't know how else to
I know my title may be a little convoluted but I am really quite
Ok, my title may sound confusing, but I don't know a better summarized way
the title may be a little bit confusing, but I don't know how to
I know that the title may sound absurd, but I don't know ho to
Hey all, title may be abit misleading but i didnt know the correct way
I know the title makes this sound very easy, but I have a For
I know the title of the question sounds absolutely weird but I had no

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.