• 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: Clarification on the purpose of NSUserDefaults (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Clarification on the purpose of NSUserDefaults (newbie) (From: Diego Rey Mendez <email@hidden>)

  • Prev by Date: Re: How to get the selected popupmenu item with core data
  • Next by Date: Re: Triggering change notifications when modifying custom object ivars in core data app
  • Previous by thread: Clarification on the purpose of NSUserDefaults (newbie)
  • Next by thread: Opening a NSPanel in the current virtual desktop instead of the one the app is in
  • Index(es):
    • Date
    • Thread