views:

340

answers:

1

Hi!
I've been asking lately about Obj-C circular buffer objects, assuming that would be the better way to control tons of data on a UITableView.
I have found a solution as far as Circular buffer objects go, but I've been wondering about maybe a better, faster and much more memory efficient solution: Calling my SQLite DB to update the UITableView.
In a way - the memory will be released after updating the UITableView, and there won't be any need to hold reference to the objects, which will be more efficient and memory saving than holding a constant NSMutableArray with all of the objects inside it.

How would you approach updating a UITableView with masses of data (50k objects) that are also stored on a SQLite database?

Thanks in advance, ~ Natanavra.

+3  A: 

What you are describing is exactly what NSFetchedResultsController was designed for, and is one of the huge advantages of using Core Data on the iPhone. With NSFetchedResultsController, you can set up a fetch request from your database for the elements to be displayed in your table view, and limit the batch size of items to be loaded at any given time. This significantly reduces memory consumption and loading time (I've seen 8X improvements in loading time in specific examples).

NSFetchedResultsController was designed to be integrated with a UITableView. For specific examples, I'd consult Apple's sample code, such as their CoreDataBooks one, as well as the appropriate sections in Marcus Zarra's Core Data book and the Pragmatic Programmers' iPhone SDK Development book. Both of those books have very good explanations of the core concepts.

Brad Larson
Thanks for the answer;I've looked into CoreData a while ago, but my system already uses SQLite and I don't really wish to change the core of my app.I would like to know what's you opinion about implementing the same function which NSFetchedResultsController was built for, but with SQLite.Thanks again for your answer.
natanavra
My recommendation would be to migrate your existing SQLite database to Core Data. I recently completed such a migration for my own application in order to utilize the facilities that Core Data provides. My data model was extremely complex, yet writing a migration routine for it only took a few days. You'll spent far more time implementing your own batched fetching, caching, and memory management process than you would just moving your database over to Core Data and using what it provides.
Brad Larson