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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:44:08+00:00 2026-06-17T22:44:08+00:00

i have been working on a app, and needed to store a string. I

  • 0

i have been working on a app, and needed to store a string. I used this code to set the default:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:CertificateKey.stringValue forKey:@"SavedKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"%@",[defaults objectForKey:@"SavedKey"]);

I loged it, so i know it saved…well, it showed me the value.
When i open my application, I use this to retrieve the default:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[CertificateKey setStringValue:[defaults objectForKey:@"SavedKey"]];
[CertificateKey setTitleWithMnemonic:[defaults objectForKey:@"SavedKey"]];
[[NSUserDefaults standardUserDefaults] synchronize];

Why will it not get the default value? Did i not completely save it?

  • 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-17T22:44:09+00:00Added an answer on June 17, 2026 at 10:44 pm

    Don’t quit the application by pressing the stop button in xcode. Instead, quit it by right clicking on the application icon and selecting “Quit”.

    Edit

    Maybe the first time that you execute the application, you want to save some defaults but you don’t want to set them the second+ time that the application runs.

    For this purpose in some class initialize method register the defaults, like this:

    + (void) initialize
    {
        NSUserDefaults* defaults= [NSUserDefaults standardUserDefaults];
        [defaults registerDefaults: @{} ];
        // This case it's an empty dictionary, but you can put whatever you want inside it.
        // just convert it to data if it's not an object storable to a plist file.
    }
    

    Also, you’re using setValue:forKey: , that method is inherited from NSObject. Use setObject:forKey: .

    And use finalize if you want to save the defaults at the end:

    - (void) finalize
    {
        // Save the defaults 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 this app for at least 3-4 months and just
I have been working on an app, where you set up a list of
I have been working on the app engine for some time, and this problem
I have been working on an app where I have successfully shown my location
I have been working on an iOS App for sometime now and its almost
I have been working on a django app on my local computer for some
I have been working on getting a mail app to work from a tutorial
I have been working on a Windows Mobile app for a little while now
I have been working on a small php app (400K total). But in the
I have been working with a Windows Mobile 6 app that is built with

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.