views:

43

answers:

2

Hi,

Pretty new to iOS dev, I feel I have a grasp of the basics. I was thinking through an app I would like to make and the steps involved, components needed... and I have no idea how to or what is the best method to save user input and retrieve it.

An example being (I don't plan to make this, but it illustrates what I want to know), say a simple to-do list, it has NSTableView that is populated from NSMutuableArray, to begin with it is blank as the user has added nothing. Once an item is added to the array, table reloads thanks to -reloadData. The item that is needed to-do is shown in the table. Great for this session... but not when the app is reopened.

I imagine I need to store the array and then reload it when the app next initialises, is this correct?

Or is there any other better method?

+3  A: 

If you're just starting out. The best way to go is to use Core Data to save and display your data. You'll thank me in the end.

http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/CoreData/cdProgrammingGuide.html#//apple_ref/doc/uid/TP30001200-SW1

Tutorials

http://www.raywenderlich.com/934/core-data-tutorial-getting-started http://developer.apple.com/cocoa/coredatatutorial/index.html http://themikeswan.wordpress.com/2009/05/22/7/

Do a google search there are lots of resources.

Jordan
Thanks, for some reason I was thinking CoreData was only OSX, the books I have been reading fail to mention it.
S1syphus
They were probably written before CoreData was introduced in iOS in version 3.0.
Jasarien
If you start Xcode and ask it to create a new navigation based app and tick the "use core data" checkbox, the skeleton app it gives you is about 50% of the way there.
JeremyP
+2  A: 

In addition to Jordan's answer, mostly for completeness so you understand your options. You have at least another two options:

Both these concepts are easier to understand than a proper relational database and are for simpler things worth considering. Especially since TODO lists are not likely to contain large amounts of data.

Property Lists is the easiest and most basic one in terms of functionality. It just lets you store primitives, but is good if your TODO list is just a collection of Strings.

Serilization using NSCoding is more powerful, but requires more work from the developer. With NSCoding you can create your own coders/decoders for your business objects that lets you persist the entire state. This would be good if you have your own Todo with a lot of properties, like title, priority, complete-by-date etc.

willcodejavaforfood
These are valid, but as you go from a TODO list to something more complicated, you'll want to know how Core Data helps make your job as a programmer easier. My second choice would be NSCoding. But NSCoding is more for the intermediate programmer. Property Lists, you want to know about now, just so you know how to read and store plists. But again, if you're just starting out Core Data is the way to go. You'll learn alot about programming going through the process.
Jordan
@Jordan - I did not think your answer was wrong, I just listed the options :)
willcodejavaforfood
@willcodejavaforfood, didn't mean to sound defensive ;)
Jordan