Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Storing an Array as an object for NSUserDefaults

Storing an Array as an object for NSUserDefaults
Thread Tools
Mac Enthusiast
Join Date: Apr 2001
Location: Newton, MA, USA
Status: Offline
Reply With Quote
Jul 1, 2003, 06:45 PM
 
Howdy...

i'm having a bit of trouble with the storage of user preferences with my little project. So, i've got an NSPopUpButton with a menu, and i use its itemArray method to return an array of the NSMenuItems therein. When i initialize the preferences, it doesn't complain, but later on, when i go try to make an update to them with:

[[NSUserDefaults standardUserDefaults] setObject:[alarmTimePresetMenu itemArray] forKey:@"Preset Menu"];

i get an error "Attempt to insert non-property value..." in the log while the program runs. Not sure where i'm going wrong, but someone said that NSUserDefaults can only tolerate strings in this usage, despite the fact that the documentation indicates otherwise.

Anyone have any thoughts?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jul 1, 2003, 07:38 PM
 
From the documentation:
Recall that a default's value can be only an NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary.
You are trying to insert an array of NSMenuItems, so it won't work.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:45 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2