• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Forcing NSUserDefaults being written to disk?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing NSUserDefaults being written to disk?


  • Subject: Re: Forcing NSUserDefaults being written to disk?
  • From: Marco Binder <email@hidden>
  • Date: Thu, 9 Jan 2003 15:44:49 +0100

I m not sure about this, but if I remember correctly, only keys with values differing from the registered ones are actually being written out to file. I always thought thats the reason, why one would register defaults after all.

Leave away the registering part and just use [[NSUserDefaults standardUserDefaults] setObject: myObject forKey: @"key"] and then call synchronize. At least for me, this works.

Registering means, you specify the standard settings that are used if nothing is specified in the preferences file (e.g. first run on a users system). If you set a key to some different value afterwards, this altered value WILL be saved. Like in:

[defaults setBool:![defaults boolForKey:kKey_VerticalSync]
forKey:kKey_VerticalSync];

If you restore it to the standard, I even assume, that it will disappear from the file again (not sure on that though).

Again: that4s how I remember things. I might be wrong. Just try my suggestion.

marco


Am Donnerstag, 09.01.03 um 10:18 Uhr schrieb Scott Anguish:

On Wednesday, January 8, 2003, at 03:51 PM, Pierre-Olivier Latour wrote:

Hi,

I have an application that has no UI. Its settings have to be set by editing
its defaults file (.plist). I use the following code to register the
defaults at startup:

<snip>

My problem is that, even if I call [[NSUserDefaults standardUserDefaults]
synchronize] when application quits (it returns true), no file is written in
~/Library/Preferences/;

According to the doc, it should be written when you call synchronize, even
if no changes have been made to the defaults...


There is likely no domain being specified to use to store the defaults in. Normally this is picked out of the Info.plist key CFBundleIdentifier in the application wrapper.

You need to set the identifier in the target of your application.. unless it is a wrapperless tool.. Instead you're going to have to set the domain programmatically.



PS: I assume synchronize if buggy.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Forcing NSUserDefaults being written to disk?
      • From: Pierre-Olivier Latour <email@hidden>
References: 
 >Re: Forcing NSUserDefaults being written to disk? (From: Scott Anguish <email@hidden>)

  • Prev by Date: Non-activating panel not working
  • Next by Date: Re: Configuring network prefs programmically
  • Previous by thread: Re: Forcing NSUserDefaults being written to disk?
  • Next by thread: Re: Forcing NSUserDefaults being written to disk?
  • Index(es):
    • Date
    • Thread