• 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: Another user defaults question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another user defaults question


  • Subject: Re: Another user defaults question
  • From: Chris Parker <email@hidden>
  • Date: Thu, 24 Aug 2006 16:22:11 -0700


On Aug 24, 2006, at 4:11 PM, Ivan Kourtev wrote:

After extensive reading of archives and documentation I am still having a hard time getting the workings of NSUserDefaults. So here are a couple questions:

1. I can successfully "register" defaults using a dictionary of keys and values and - [NSUserDefaults registerDefaults]. But nothing seems to be written to a file in the ~/Library/Preferences folder? Is that normal? Does it mean I have to - [NSUserDefaults registerDefaults] every time the application starts?

Yes. -registerDefaults sets up "backstop" preferences in the registration domain. The registration domain is never written to disk by any -synchronize call.


People typically deal with this by putting a plist in their app's Resources directory, reading that plist in and then calling - registerDefaults with the contents of the plist.

2. It seems that via - [NSUserDefaults registerDefaults] one can only register defaults that are (or have been converted to) objects because only objects can be inserted into the dictionary that is a required argument. But the NSUSerDefaults class also has things such as setBool/Float/Integer: forKey: Isn't that a contradiction -- to be able or not be able to register certain types of default values directly depending on which method you use?

setInteger:forKey: and other like methods are convenience methods which box the value argument in the appropriate plist type for storage in the NSUserDefaults system.


--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Another user defaults question (From: Ivan Kourtev <email@hidden>)

  • Prev by Date: Re: Another user defaults question
  • Next by Date: Re: printShowingPrintPanel & memory leak
  • Previous by thread: Re: Another user defaults question
  • Next by thread: Drag between 2 NSTableView?
  • Index(es):
    • Date
    • Thread