Home > Articles > Programming > General Programming/Other Languages

  • Print
  • + Share This
This chapter is from the book

When to Use Core Data

Once your application outgrows trivial “settings” storage, such as NSUserDefaults and property lists, you’re going to run into memory usage issues. The solution is to use a database either directly or instead indirectly with Core Data. If you choose Core Data, you’ll save time otherwise spent coding a database interface. You’ll also enjoy big performance gains, as well as some functional benefits such as undo and validation. The time you would have spent developing, testing, and generally speaking “reinventing the wheel,” you’ll free up to focus on more important areas of your application.

Now you might be thinking, “I just want to save lots of stuff to disk, so why does it have to be so complicated?” Well, it’s not that difficult once a few key points are understood. Sure, you could write your own database interfaces and they would probably work great for a while. What happens, though, when your requirements change or you want to add, say, data synchronization between devices? How are your skills at building multithreaded data-import routines that don’t impact the user interface? Would your code also support undo and validation yet still be fast and memory efficient on an old iPhone?

The good news for you is that all the hard work has already been done and is wrapped up in the tried and tested Core Data Framework. Even if your application’s data requirements are minimal, it’s still worth using Core Data to ensure your application is as scalable as possible without compromising performance.

Once you start using Core Data, you’ll appreciate how robust and optimized it really is. The millions of people worldwide using Core Data applications every day has led to a mature feature set with performance to match. In short, you’ll save more time learning Core Data than throwing it in the too-hard basket and writing your own database interfaces. You’ll also benefit from loads of additional functionality for free.

  • + Share This
  • 🔖 Save To Your Account