ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.85k stars 2.77k forks source link

There is a way to cache the result like the NSFetchedController used in Core Data #172

Open Piero87 opened 11 years ago

Piero87 commented 11 years ago

Hello, i think this project it's amazing, i want to leave the Core Data to use this, but i want know some information if possible, in core data to reload a table view there is the NSFetchedController, that doesn't reload the data every time, but reload it when it necessary, so the reload of a UITableView is very fast (or i think do this maybe i wrong) in my project i have a UITableView that load the row from a query in the DB, so in the ViewWillAppear every time i call the method that query the DB, insert the information in a Array and reload the table view, but when the row in table view increase, the view takes time to appear, instead in Core Data the view display faster, so my question is, there is a way to for example cache data? to check if something change and need to make the query again?

Another question, to make the query faster i have add some index, i have to create an index also for the primary key?

ccgus commented 11 years ago

There aren't any examples for this- you'll just have to cache the results yourself.

Piero87 commented 11 years ago

thanks for the answer, but it's possible to do? can you make me a simple example, to have an idea of what i have to do?

i want know also another question i have to insert an index also for the primary key in a table? or is already created?

danielmj commented 9 years ago

It is possible to do, just much harder. This may be why there are not many simple solutions. Because of this, I am actually working on a script to emulate the NSFetchedResultsController using FMDB.

You can check it out here: https://github.com/danielmj/SQLFetchedResultsController