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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:55:58+00:00 2026-05-27T02:55:58+00:00

So I grab the username from the field, save it in an NSString variable:

  • 0

So I grab the username from the field, save it in an NSString variable:

    loggedInUser = [usernameField stringValue];
    [loginWindow close];

Later, I try to access that loggedInUser data:

    NSLog(@"Logged in User:%@", loggedInUser);

This often, but not always, gives an error:

    Program received signal: "EXC_BAD_ACCESS". // Summary displays "{...}" for the value

The loggedInUser NSString gets cleared? What happened? (I never modify this value myself).

My only thought is that I am somehow saving the continued value of the NSTextField in the NSString. Then, when I close the window, that value is cleared.

Is that what’s happening? How do I save that Textfield value in a safe way for continued use?

  • 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-27T02:55:58+00:00Added an answer on May 27, 2026 at 2:55 am

    Ahhh, I just realized what is going on.

    When you close your window (and it likely gets released), the string that you assigned to your object’s NSString variable is autoreleased as well.

    You need to explicitly retain it.

    Or, more to the point, do this:

    loggedInUser = [[NSString alloc] initWithString: [usernameField stringValue]];
    

    or:

    loggedInUser = [[usernameField stringValue] copy];
    

    don’t forget to release loggedInUser when your dealloc method is called (assuming you’re not using ARC here).

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

Sidebar

Related Questions

I have been working on a code that will grab the userName from the
My login system currently works as follows: Grab the user's username and password from
I want to grab the value of a hidden input field in HTML. <input
I'm trying to grab data from a MySQL database. Approach 2 - apply/map style
I'm currently trying to grab a file from an external url that has an
How do i grab the link href (under the published node) from this xml:
I would like to access profiles table from my Profile model which belongs_to :user
I have an application which connects to a database, retrieves a username from a
I'm trying to make a request using dojo.xhrGet to grab some XML data from
I have some Python code that uses Paramiko to grab build files from a

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.