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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:59:25+00:00 2026-06-02T23:59:25+00:00

I have a couple questions regarding application preferences using NSUserDefaults. In my last app

  • 0

I have a couple questions regarding application preferences using NSUserDefaults.

In my last app I would link my preferences using bindings to NSUserDefaults, and this worked perfectly. In the application startup methods I could then perform actions based on the values stored in the NSUserDefaults.

The problem occured when I updated my application and re-distributed it, in which all the settings would get over-written with the preferences in my computer. So if someone changed the settings, and then received the update, their settings would get over-written with mine.

Looking back at the Apple documentation in regards to saving Preferences, I notice the following line which I didn’t use, which is used to write preferences to disk:

[defaults synchronize];

My question is, does this code write the preferences to the user’s harddrive, so that if I re-distribute the application with different settings, NSUserDefaults will read from the disk instead?

Sorry for the misunderstanding but I can’t find an answer.

Thanks in advance 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-06-02T23:59:26+00:00Added an answer on June 2, 2026 at 11:59 pm

    If you want to use bindings to control your preferences, you should be using NSUserDefaultsController. In either case, to set initial values for your defaults, you should create a dictionary with the initial values and then pass it to registerDefaults: if you’re using vanilla NSUserDefaults, or one of initWithDefaults:initialValues: or setInitialValues: if you’re using NSUserDefaultsController. Here’s an NSUserDefaultsExample:

    - (void)applicationDidFinishLaunching {
        // For decent-sized applications, I normally like to store this in its own plist
        // but I'm creating it in-line here for readability's sake.
        NSDictionary *initialPreferences = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSNumber numberWithInteger:21], @"UserAge",
            @"red", @"FavoriteColor",
            @"Idaho", "Location", nil];
        [[NSUserDefaults standardUserDefaults] registerDefaults:initialPreferences];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of questions regarding a modular GWT based application framework. I
I have a couple of questions regarding using Google maps API, especially the Places
I have a couple questions regarding using the entity manager in a JavaSE environment.
I have couple questions regarding some C++ rules. Why am I able to call
I have a couple of questions regarding facetting in ggplot2... Let's say I have
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
I have a couple of questions regarding MySQL indexing: 1) Is there any speed
I have a couple of conceptual questions: regarding serving static files (media) in Django
I've read a couple similar questions regarding this topic on StackOverflow, but none of
I have a couple of questions regarding the following: [DllImport(libmp3lame.dll, CharSet = CharSet.Ansi)] static

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.