Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving arrays with NSUserDefaults?



On Jun 29, 2004, at 4:53 PM, Jonathan del Strother wrote:

I'm having trouble saving an array into NSUserDefaults.

[ [NSUserDefaults standardUserDefaults] setObject:presets
forKey:@"GLPresets"];

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

@interface Preset : NSObject

The only objects that can be stored in NSUserDefaults are NSString, NSData, NSNumber, NS(Calendar)Date, NSArray, and NSDictionary. If you want to store these Preset objects inside the user defaults, then you will need to make the Preset class compliant with the NSCoding protocol, and then use NS(Keyed)Archiver & NS(Keyed)Unarchiver to store & extract the objects in/from the array.

You can probably find out more about NSCoding by searching the ADC site.

Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.