Deploying sqlite DB on iPhone app upgrade

前端 未结 2 976
无人及你
无人及你 2021-02-01 10:14

I\'m using sqlite as a datasource in an iPhone app. I have two questions regarding application upgrades.

1.) The data is all config/nontransactional. Meaning, it is rea

2条回答
  •  不思量自难忘°
    2021-02-01 10:46

    cdespinosa has described scenario #1 well, so I'll tackle #2.

    I haven't done this on the iPhone yet, but on a desktop environment the easiest way to handle this is to keep your configuration data in a separate database. You can attach to multiple databases rather easily. Start by opening your main database, which should probably be the database that can change. Then sqlite3_exec an ATTACH statement, which looks like this:

    ATTACH 'filepath' AS config;
    

    From then on, you can do something like this:

    SELECT * FROM UserTableName;
    SELECT * FROM config.ConfigurationTableName;
    

    It's my understanding that if you write to the configuration database the application will fail a signature check and won't start, and the version of SQLite included with the iPhone is old enough to not support the read only flag. For this reason, you should copy your configuration database file into the sandbox and open that copy instead of the one in your bundle.

    (You can, of course, use SQL and copy the values from one database to another. But if you're already copying the entire configuration database to your sandbox... and you should be... then that's just an extra step. Just attach.)

    I hope someone else can provide you with more details. :)

提交回复
热议问题