Search code examples
objective-csqlitecore-datansfetchedresultscontrollerfmdb

Is there any way to be notified when sqlite tables update?


I am developing an iOS app that uses sqlite database with the help of FMDB. I used to work with Core Data, but it was very slow with 5000 items insert at a time. FMDB with transactions make such inserts much more faster!

Also I need some mechanism that can notify my view controllers when some items from sqlite table are updated. NSFetchedResultsController was my solution, but since I use FMDB I can no longer use NSFetchedResultsController.

Is there any way to be notified when sqlite tables update?


Solution

  • I have been searching for a while and found a solution. I wonder why I haven't found it earlier.

    My choice now is YapDatabase. I don't know about its weaknesses but there are so many great things about this library:

    • Regularly updated. Has more then 1000 commits! Wow!
    • It's a key/value store. I'm just saving my NSDictionaries. No more data models and headaches.
    • Perfomance is great. I have compared to Core Data delete + insert speed.
    • And the most great thing is "Views":

    Views allow you Sort, Group & Filter your data. Perfect for tableViews, collectionViews, and more. And they even provide NSFetchedResultsController style updates to make it easy to animate changes to your tableViews/collectionViews.