• 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: Saving arrays with NSUserDefaults?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving arrays with NSUserDefaults?


  • Subject: Re: Saving arrays with NSUserDefaults?
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 29 Jun 2004 19:53:02 -0700

Hello...

In addition to the option of archiving objects of your Preset class as Nick suggested, another option would be to use an NSDictionary to hold your presets instead of a custom class.

If your Preset class has methods besides regular accessor methods, then you could instead implement an initializer that takes an NSDictionary of presets and initializes an instance of Preset with those values, and an instance method that exports itself as a dictionary.

Since all of the instance variables in your class can be represented as property list objects (storing the floats, BOOLs, and ints in a NSNumber), the dictionary could be stored normally in the user defaults without archiving.

Louis

...
'presets' is an NSMutableArray consisting of several of these:

@interface Preset : NSObject
{
NSString* name;
float intensity;
float sensitivity;
float fade;
float zoom;
float zoomRotation;
int numLines;
float r1,g1,b1;
float r2,g2,b2;
bool smooth;
bool glow;
bool cycle;
bool sharpOverlay;
int scaleSystem;
};
@end;

...
Thanks,
Jon
_______________________________________________
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: 
 >Saving arrays with NSUserDefaults? (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: selector not recognized
  • Next by Date: NSCursor category
  • Previous by thread: Re: Saving arrays with NSUserDefaults?
  • Next by thread: [ANN] Free NSValueTransformer classes.
  • Index(es):
    • Date
    • Thread