作者:季孙意如 | 来源:互联网 | 2023-07-08 15:30
IamhavingtroublecomingupwithanefficientwayofdeletinginformationfromaSQLiteDBaftera
I am having trouble coming up with an efficient way of deleting information from a SQLite DB after a JSON response.
在JSON响应之后,我无法想出一种从SQLite DB中删除信息的有效方法。
Basically how what I am trying to do is:
基本上我要做的是:
I have a DB with 100 records.
我有一个有100条记录的数据库。
- I read the first record
- 我读了第一张唱片
- Build a JSON package and send it to my API.
- 构建一个JSON包并将其发送到我的API。
- WAIT for the API to respond Ok or Fail
- 等待API响应Ok或Fail
- The delete the record from the DB on OK.
- 确定从DB中删除记录。
- Move to the next record.
- 移至下一条记录。
There is some time between waiting on a response before I can delete and go on.
在我可以删除和继续之前等待响应之间有一段时间。
A simple FOR doesn't seem to work as it can't wait for the 'OK' from the API.
一个简单的FOR似乎不起作用,因为它不能等待来自API的'OK'。
I looked into dispatch_async(dispatch_get_main_queue());
but if the OK comes and the DB is processing it will lock the DB while it is being accessed and the logic fails because the db is locked.
我查看了dispatch_async(dispatch_get_main_queue());但是如果确定来了并且数据库正在处理它将在访问数据库时锁定数据库并且逻辑因数据库被锁定而失败。
I need a mixture of the two. Does anyone know of a tutorial or where to start with something like this?
我需要两者的混合物。有没有人知道一个教程或从哪里开始这样的事情?
3 个解决方案