Вопрос

I want to leave the Core Data to use the FMDB, 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?

Это было полезно?

Решение

I would suggest you first get familiar with some elementary concepts:

  • "Core Data in FMDB" is impossible. FMDB is a wrapper around the SQLite api, not around Core Data. Core Data is an object graph, not a database.
  • If you want to use Core Data, throw out FMDB (which I recommend).
  • In Core Data the fetched results controller uses a cache mechanism that makes tables very fast and efficient with resources.
  • In Core Data's managed object model editor, you can easily mark attributes to indexed for faster fetches.
  • Core Data has many more mechanisms to boost performance, such as fetch batch sizes, faulting and fetch request templates.
  • Core Data does not use foreign keys, but so-called relationships. The foreign-key concept is completely hidden and just an implementation detail. You should understand the difference between a relational database (SQLite) and an object graph (Core Data).

Read all about it here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top