I am having difficulty deciding which is the best method for saving my app data.
It is a recipe app.
I have an array of category class objects that contains an NSString variable for the category title and an NSMutable Array of Recipe class objects (which contains 3 NSString variables).
here is a semi-visual representation of my app model:
Array of Categories contains:
- Category Object 1–>contains string title and mutable array of Recipe Objects
- Category Object 2–>contains string title and mutable array of Recipe Objects
…
etc.
Users are able to create new recipes and the recipe object is stored within a selected category object.
On app load x amount of categories are created (depending on value of a numberOfCategories int). and of course upon relaunch I want to restore the recipes to their appropriate category objects.
Hopefully that wasn’t too confusing–I was going the NSUserDefaults way and doing the NSCoding thing to encode/decode my custom objects but found it confusing because I have an array of custom objects that contains an array of custom objects.
I am open to the idea if it is the best route of converting my project to use Core Data–but that also seemed overly complicated for the simplicity of my app (pre-populating my SQLite database with categories, etc etc).
Let me know if you need further clarification.
Use CoreData. Sounds like you will need at least two separate entities and establish a relationship between them (Recipe and RecipeObject). NSUserdefaults is great for storing small amounts of data that needs to be persisted, but not really good for your use case.
Also, check out MagicalRecord and MOGenerator. Both of these open source libraries make working with CD much more fun and productive.