Re: Clarification on the purpose of NSUserDefaults (newbie)
Re: Clarification on the purpose of NSUserDefaults (newbie)
- Subject: Re: Clarification on the purpose of NSUserDefaults (newbie)
- From: Fritz Anderson <email@hidden>
- Date: Thu, 28 May 2009 13:57:37 -0500
On 26 May 2009, at 6:34 PM, Diego Rey Mendez wrote:
I'm new to development on the iPhone. I have been reading for a
while now
the official docs, and some tutorials and posts online explaining
the use
of NSUserDefaults.
My questions:
1) It sounds to me as if this is the preferred class for storing the
user
preferences for my application, right?
Right.
2) What's the preferred class/method for storing larger chunks of
data? Is
it NSFileManager?
That depends on what you're storing, how much, and what you're
comfortable with. Here are the methods I can think of in two minutes
at the keyboard:
1) If it's less than a few thousand Cocoa objects, implement
<NSCoding> and use NSKeyedArchiver and NSKeyedUnarchiver. You get a
lot for free.
2) If it's a lot of data, use the SQLite3 database library.
3) Use POSIX I/O primitives, if your code already relies on them or
you're most comfortable with them.
4) There are content-reading and -writing methods in NSFileManager, if
it's practical to work with NSData as the input and output.
5) NSString, NSDictionary, NSData, and NSArray all
have ...WithContentsOfFile or ...URL methods, and symmetric writers.
The container classes have to contain only NSCoding-compliant objects.
You have lots of options. You might get better answers if you can tell
us what you're trying to accomplish.
See "iPhone Application Programming Guide," chapter "Files and
Networking;" and "Archives and Serializations Programming Guide for
Cocoa."
— F
--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden