• 0

[Objective-C] Storing large amounts of data using Core Data?


Question

I am building an application (for iPhone, using Objective-C) which asks users a series of questions. I'm not sure how I should store the data. For privacy reasons, I think having a local database (not stored in the cloud) is ideal.

Core Data seems to be very easy to use, but I'm wondering whether it is suitable for storing large amounts of text (the questionaire has hundreds of questions, and each response would be a variable-length string, but the answers could potentially be long). Is Core Data a suitable way to store this data? Or should I investigate something else like SQLite?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

SQLLite is what you want to do but keep in mind that SQLite data on your app will be removed once the app is uninstalled but so will any other physical files you installed/generated so it's kind of a wash.

SQLLite is fairly simple and probably the best way for you.. read through this

http://klanguedoc.hu...tive-C-C-How-To

However, Core Data is more then just keeping records.. while SQLLite might be better for searching and retrieving data without tying up your memory footprint, Core Data will provide you with far more flexibility when it comes to managing connection between objects and the chain of events/states between those objects you can attach arbitrary code to handle which is something that database (SQLite) doesn't do.

Most often, Core Data will hold most of the data persistent in memory although it's not mandatory. It is recommended to use Core Data for keeping track of application states, relationship between objects but use SQLite when you need data to be persistent but not in memory and requires simpler search, retrieve functionality.

Also, some things Core Data won't do when compared to SQLite:

1. Core Data cannot operate on data without loading the data into memory

2. Core Data does not handle data logic (data-related features SQL contains, such as unique index keys)

3. Core Data does not offer any amount of threading support. Granted SQLite is single threaded too but there will be scenarios where you will want multiple threads reading your data. NSManagedObjects and their NSManagedObjectContext operate on a single thread only (or should be). If you want another thread dealing with the same dataset, you need to save the data from memory and then reopen with a different NSManagedObjectContext on another thread which creates latency and is not ideal.

Btw, this is a great chart that explains when and why you should use Core Data vs SQLite (database)

2012-02-03_110838.png

Link to comment
Share on other sites

  • 0

Core Data can easily handle the amount of information you want to throw at it.

Excellent. :D
Link to comment
Share on other sites

This topic is now closed to further replies.