Difference between core data & NSUserDefaults-note

2019-07-04 23:02发布

问题:

Creating a budget app (not for release, just something quick & dirty) and I noticed upon starting the Master-Detail template that Apple uses Core Data and NSFetch results to populate the tables (think Notes on an iPad).

My inexperienced and unprofessional programming instincts wouldn't think twice about grabbing an NSMutableArray, taking the names of the table cells and cramming them into an index, saving that as an NSUserDefault and then upon reloading the app, populate each cell at it's current index with the same index in the NSMutableArray so the contents is back where the user left it. Just wondering, how inefficient is this compared to using Core Data?

On a side note, any easy way of communicating between two different tables that both hold dynamic data?

回答1:

Up to a few hundred records, don't worry about it. It would be indeed wonderfully "quick and dirty".

Still, the learning curve for Core Data is not as steep as you might expect. Once you get the hang of it - and your simple app is great way to explore that API - you will find that you want to do everything with it. Even large projects will seem easy.

Your choice.