I've a selector that updates my sqlite (FMDB framework) database fillTopXTraps
.
When I call the selector up updates 2 separate databases, it fails in 'DataBase' class (shortly -> 'db').
And I've this error:
The FMDatabase is currently in use.
multiple times.
I tried to call fillTopXTraps
using:
[databaseQueue addOperation:invokeOperation];
[databaseQueue waitUntilAllOperationsAreFinished];
And I've an error 'database is locked' and:
[NSOperationQueue addOperations:waitUntilFinished:]: 1 (of 1) operation is finished, executing, or already in a queue, and cannot be enqueued
I tried using FMDatabaseQueue and still have an error 'database is locked' and '...currently in use.'.
How can I make sure fillTopXTraps
will not continue if its already being processed and will know to wait until finished and then continue.
Or maybe the problem is the database which is called from multiple thread apparently, how can I fix it?