Fetchnotes/forge-sqlite — pull request #5 by gilesvangruisen (2014-07-08 21:41:13+00:00)
Title: [not ready] Don't block UI

First off: this needs to be tested before anything happens, but a code review from a fellow Obj-C-er would be appreciated.

This uses a class called FMDatabaseController to wrap db calls in a dispatch block and sends them off to be performed off the main thread (thus no longer blocking the UI). That class is basically a singleton: call controller on the class to return a shared instance of FMDatabaseController, upon which you can call queueInDatabase: to perform a query/transaction.

queueInDatabase: takes a void block with parameter FMDatabase, just like FMDatabaseQueue inDatabase:

Since queries generally happen pretty quickly, there aren't many cases in Dachshund where this becomes a problem. The only one I can think of that (should) be alleviated by this change is the initial note load. That dog jump animation can get glitchy. Now that should be a bit smoother!

I also feel like it's generally good to be running these things off main thread. (Not to mention it will make Dachshund migration stuff much smoother)