You can use lock (such as those enumerated in the Synchronization section of the Threading Programming Guide) or you can use a dedicated serial queue. For example, create a queue:
Instantiate it:
And whenever you want to interact with the database, you can do
If you want to simplify your life, the FMDB library has a FMDatabaseQueue object that does much of this for you (as well as greatly simplifying your database interaction in general).for more detail read http://stackoverflow.com/questions/20029782/how-to-handle-multiple-thread-access-the-sqlite3-with-out-dblocked-error |
Friday, 12 December 2014
SQLite3 thread safe execution in iOS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment