Re: NSUserDefaults and objects
Re: NSUserDefaults and objects
- Subject: Re: NSUserDefaults and objects
- From: j o a r <email@hidden>
- Date: Sun, 12 Mar 2006 21:21:02 +0100
On 12 mar 2006, at 19.50, Alan Smith wrote:
I want to store an array of objects in the user defaults for
retrieval when
the program launches next time. The objects have two attributes, two
strings. One is the name of an app and the other the path of that
app. It
also has a couple of methods with it. But when I try setObject:
forKey:, or
whatever it is, it complains about the objects in the array. So is
there a
way to encode, or something, these objects so they'll go in and
come back
out as my object type?
As is documented, NSUserDefaults only accepts "property list objects":
<http://developer.apple.com/documentation/Cocoa/Conceptual/
PropertyLists/index.html>
You need to archive your objects if you want to persist them in user
defaults:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/
index.html>
...and unarchive them after you get them out from user defaults.
And one more thing. The dock has a file in
Dock/Contents/Resources/English.lproj/defaults.plist. I uses this
the first
times it's launched and adds apps to the dock according to the
arrays in
that plist file. I want my app to have the same thing. A previously
saved
pref file and store it in the apps bundle so that when it gets run on
someone elses computer it has a pref file to load, with apps in it.
Great, so do it. Or wait, was there a question in there?
<http://www.catb.org/~esr/faqs/smart-questions.html#explicit>
You might get what you're looking for by using NSRegistrationDomain.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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