• 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
NSUserDefaults and non-property-list objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUserDefaults and non-property-list objects


  • Subject: NSUserDefaults and non-property-list objects
  • From: Larry Gerndt <email@hidden>
  • Date: Wed, 15 Jun 2005 14:23:42 -0700

Apple documentation points out that although NSUserDefaults object support extends only to property list types (NSData, NSNumber, NSArray, etc), one can easily add a category to NSUserDefaults and define methods therein to support converting other types (such as NSColor) to NSData.  But if I use this technique, how do I go about creating a dictionary of these non-standard defaults that can be passed to registerDefaults:?  The methods that do the conversions to NSData are in the category of NSUserDefaults, not NSMutableDictionary, so it would appear I would have to duplicate those methods elsewhere to be able to do the conversions

One possible solution I can think of is:  instead of putting the conversion code into the NSUserDefaults+Extensions methods, I could add a category to each class type that needs converting, for example  an NSColor+Extensions method:  -(NSData*)colorAsData;  Then that could be used both when creating items for the defaults dictionary and also be used by the NSUserDefaults+Extensions category methods.   Is that a sensible approach?


--

Larry Gerndt

AIM Handle: SonOfTheSonOfMan

Let the truth be told though the heavens fall -- James Garrison


 _______________________________________________
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: NSUserDefaults and non-property-list objects
      • From: Larry Gerndt <email@hidden>
  • Prev by Date: Odd tooltip behavior in NSTableView
  • Next by Date: Re: NSUserDefaults and non-property-list objects
  • Previous by thread: Re: Odd tooltip behavior in NSTableView
  • Next by thread: Re: NSUserDefaults and non-property-list objects
  • Index(es):
    • Date
    • Thread