I am working on a navigational app where i have my entries of recipes. What I need is to implement a button which will add a recipe on a favorites tab.. How can I do that? Any help would be appreciated.
A:
One reasonable strategy is to manage an NSMutableArray or NSMutableDictionary in your app, and write to to the documents folder as a property list - eg
[myArray writeToFile:path atomically:YES];
and read it back with:
myArray = [NSMutableArray arrayWithContentsOfFile:path];
Another option, which is used in MacOSX Recent menu, is to save the entries via NSUserDefaults
. You can choose.
Paul Lynch
2010-04-09 21:16:40
Thank you very much for your help.Another question:As i previously mentioned i have a table with the names of the recipes and when you click on a cell, you are navigated to the recipe which is stored on a text view.On this "detail view", i will have a button which will add it to favorites..What I want to do is to add one more tab to my app, under the name of "Favorites" which will present a table with the name of the recipes(The "favorite" recipes[the ones on which we clicked the button]) and when you will select a cell you will be navigated to the exact recipe.
zacharisharris
2010-04-10 14:02:18
If you always write to the plist when you add an entry, and read it during viewWillAppear into your Favorites controller, then that's all you need to do. This sort of application can also be implemented with CoreData, and as it gets more complex that's a better way to go. But a simple app can work very well with just plists.
Paul Lynch
2010-04-10 14:59:31