Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use Core Data for my iPhone app?

I'm working on my 2nd iPhone app and am curious about Core Data. Time on the project is limited, as is my time overall.

I'm the only dev and I have a feeling that Core Data would be useful but I can't clearly explain why.

Please excuse the following obfuscation .. the app needs to retrieve a list of foos from a central server. Users can then add a bar, from a list of bars, to the foos, then add a baz from a list of bazes(!?) to the bar, then add some optional photo and description to the baz.

Once the user is happy with their bar and baz work they then hit a sync button to upload their data back to the central server.

As you can see, it's a simple data driven drill down app, but I'm still not sure I can justify using Core Data with our time constraints - the learning curve looks steep.

If argue to my boss that we should be using Core Data, what bullet points can I shoot at him? Logic grenades are also appreciated.

like image 829
nikkumang Avatar asked Dec 10 '09 20:12

nikkumang


People also ask

Should I use Core Data iOS?

The next time you need to store data, you should have a better idea of your options. Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.

What is the use of Core Data in iOS?

Overview. Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.

What should Core Data be used for?

Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.

Should I use realm or Core Data?

If your project requires encryption or speed, then Realm is an obvious choice. If your project has a complex data model that changes frequently, then Core Data might be a better choice.


1 Answers

Core Data will mainly help in the auxiliary facets of the application - things like data persistence, presentation, etc. Some bullet points for your boss:

  • Core Data manages save and undo functionality for you. It has a persistent store, which tracks changes, and can be flushed to the disk automatically at any number of times (app close, etc.).
  • Core Data and related classes provide easy ways to get your entities into UITableViews, like NSFetchedResultsController.
  • Core Data abstracts away a lot of the messy things you'd otherwise have to deal with yourself, such as lists of objects, one-to-many or many-to-many relationships, or constraints on object attributes, into a single nice clean object-oriented interface.
  • Core Data comes with a nice graphical object model editor that can help you think through your object/entity design, and refine it as you go. (It also supports migration, so if you decide later that you want different attributes on your entities, you can do that relatively easily.)

Sure, the learning curve may be a bit steep, but the Apple examples are great to start with, and the Core Data documentation is very complete and helpful. Once you've got Core Data down, it'll be a breeze to build your app.

like image 125
Tim Avatar answered Oct 22 '22 03:10

Tim