views:

45

answers:

1

i've had difficulty finding examples/tutorials/information for this. i'd like to have an 'add to favorites' button in my application. this would take a cell from one tableview and populate that cell into the 'favorites' tableview. is core data the proper direction for approaching this? i've seen some hints about using nsmutablearray and/or nsuserdefaults. not really sure which way to go. any advice is appreciated.

A: 

Core Data is likely the best way to go if you need a persistent store across user sessions. NSUserDefaults is more for -- just that -- user defaults. While I think it'd be appropriate to save, say, a user's home page, in NSUserDefaults, something that could get large (like favorites) should probably go in a data store.

If you never need to search the list, and you just want to save and display it, look at plist files as well. NSArray can write data directly to a plist file with writeToFile:atomically:. You can get that data back with arrayWithContentsOfFile:.

If you go with the above approach, one thing to watch out for - arrayWithContentsOfFile: is a static class method, not an instance method.

Core Data is, though, by far the most flexible option. Try the template application in XCode for "Navigation-based App" with "Use Core Data". Most of the example code is right there.

phooze
Coolbeans. Thanks for the advice! I will definitely be diving into core data.
Chunjai