On 1 Jan 2009, at 6:59 am, Chunk 1978 wrote:
ok i get that... however, what if a developer intends to leave all checkboxes in preferences unchecked as the initial defaults, and there are only checkboxes or radio buttons, no colors, no numbers, etc... is it considered bad practice to not register these defaults if they are bound? or is it better to keep code to a minimum and not register the defaults... are there any problems that can arise from not having defaults registered if their initial settings of the checkboxes is desired?
Basically if your defaults are 0, NO or NULL/nil for any setting, you can safely just not bother with registering them. That's because these are the values returned for a missing key.
You only need to register the defaults that have to be set to a value other than these. I typically design my defaults so that an absence of a value is the default default (aside: why "preferences" got changed to "defaults" is a mystery - it leads to confusion when discussing the defaults for preferences). For things like colours, you can substitute the default colour at runtime if you get a nil value back from the default - that is another way to avoid the need to use registerDefaults, but often it's useful to just use a plist with registerDefaults: so you can quickly edit the settings without hardwiring them into your code.
--Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com