How to properly call SQLite functions from background thread on iPhone?

前端 未结 8 2027
礼貌的吻别
礼貌的吻别 2020-12-29 15:10

I\'m using an SQLite database in my iPhone app. At startup, there are some database actions that I want to perform in a separate thread. (I\'m doing this mainly to minimize

8条回答
  •  心在旅途
    2020-12-29 16:15

    Your best bet is to use GCD (Grand Central Dispatch) queues to prevent simultaneous access to the sqlite database.

    Using any form of locking (including file locking that would be used by multiple database instances) may cause busy waiting which is wasteful.

    See my answer to a similar question.

提交回复
热议问题