• 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: Chris Parker <email@hidden>
  • Date: Thu, 9 Jan 2003 13:34:17 -0800

Hi folks -

On Thursday, January 9, 2003, at 2:04 AM, Pierre-Olivier Latour wrote:

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.

Unfortunately, there is one and it works, because if I do this before
calling synchronize:

[defaults setBool:[defaults boolForKey:kKey_LogFile] forKey:kKey_LogFile];

A default file is then saved to disk, but contains only the key
kKey_LogFile.

So obviously, synchronize only saves the keys that have been "touched" since
the defaults were registered. That's understandable, but I don't think this
is what the doc says i.e. defaults should be written to disk even if they
have not been updated.

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.

Maybe I could workaround the problem with that - who knows... How would you
do this?

Sounds like we might need some doc improvement in this respect as to whether the registration domain gets written out. There's a brief discussion of this in the "User Defaults" programming topic at http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ ProgrammingTopics/UserDefaults/index.html making the statement that the registration domain is volatile.

When you register a defaults dictionary using -[NSUserDefaults registerDefaults] those keys and values are placed in the registration domain. We don't write those defaults out to disk, even though they wind up in the search path.

So key/value pairs that your application registers aren't written out - they're fallback values if other values for those keys haven't been brought up from disk.

Pierre, what's happening in your case is actually the correct behavior. You've registered a bunch of key/value pairs in the dictionary, but the only one you've set via the set<something>:forKey: API is the logfile one. That key/value pair gets written out but the registered defaults don't.

.chris

--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.
_______________________________________________
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.

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

  • Prev by Date: Re: Forcing NSUserDefaults being written to disk?
  • Next by Date: Re: Crash with NSMutableArray and NSNumber
  • Previous by thread: Re: Forcing NSUserDefaults being written to disk?
  • Next by thread: Re: Forcing NSUserDefaults being written to disk?
  • Index(es):
    • Date
    • Thread