• 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: Ivan Kourtev <email@hidden>
  • Date: Thu, 24 Aug 2006 20:34:16 -0400

That's great, I think I finally got it. But how do I convert an arbitrary plist of values to the XML form?

I figured I could write the plist file the way I want it using the NSUSerDefaults system, then dump it in the plist editor and copy/ paste into a resource file. There has to be a better way to do it?

The dump contains binary data (non-human readable sequence of characters) such as

	<key>DefaultColor</key>
	<data>
	BAt0eXBlZHN0cmVhbYED6IQBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMDhAJm
	ZgEBhg==
	</data>

Is this avoidable (and how) or not?

Thanks,

--
ivan

On Aug 24, 2006, at 7:19 PM, Bill Bumgarner wrote:

That is correct. Registration defaults provide a "baseline" set of default values. Any defaults modified and stored in ~/Library/ Preferences or passed on the command line will override the registration defaults.
However, there is a much better way to do this:
Add a "RegistrationDefaults" key to your application's Info.plist. Make the value a dictionary that contains the set of registration defaults that you want to use. I.e. an entry like (you'll need to convert this to the XML form of plists):


{
... info plist content here ....
RegistrationDefaults = {
	NeutralColor = "whiteColor";
	PositiveThreshold = 10.0;
	DisplayInMenuBar = NO;
	IndexNumberFormat = "###,##0.00";
};
}

And then, somewhere very early in your app's execution:

[[NSUserDefaults standardUserDefaults] registerDefaults:
[[[NSBundle mainBundle] infoDictionary] objectForKey: @"RegistrationDefaults"]];


b.bum

_______________________________________________ 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
  • Follow-Ups:
    • Re: Another user defaults question
      • From: Stephen Deken <email@hidden>
References: 
 >Another user defaults question (From: Ivan Kourtev <email@hidden>)
 >Re: Another user defaults question (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: NSToolbar Delegates not implemented?
  • Next by Date: Re: NSToolbar Delegates not implemented?
  • Previous by thread: Re: Another user defaults question
  • Next by thread: Re: Another user defaults question
  • Index(es):
    • Date
    • Thread