I have a problem with my application (first one) when people downloading it from appstore, here is the scenario:
I have an a quiz-app with 2.174 questions in the database (core data and sqlite3). The questions resides first in a .txt file and is updated into the database based on the filename of that .txt name, which includes a date. When the app is started and finds that the file name is changed the following happens:
- Delete all records in the database
- Read in all questions and show update screen
- Display first game screen and start playing
The first version of the app had 874 questions and now i have done an update of the app plus added quite a few more questions.
When i test this on the simulator or the device there is no problems at all but i just found out that the following:
- When people that already have the app, the first version, the database updates
- When the app is downloaded for the first time 开发者_JS百科it only add 874 questions, the same as the first version of the game, but with the updated interface.
I know this is not a lot of details but the feeling I get is that the "old" version is not completely wiped out before the new version is added into the store. Also, i do not understand why there is a difference.
I guess that if i distribute a version with an already updated database it should already been updated in the appstore. If i remember correctly the new version was distributed with an updated database.
Anyone nice that have any ideas or recommendations how, and why, this is happening?
Cheers
If you would have set the version number to your database for your iphone could have been easily handle, save your version number into your db and whenever database is called, compare the version against the expected version If new version > older version change the schema and update the app version number.
It seems to me that the second version of your app does not correctly check for the (bigger) database to be copied over from the bundle to the app's documents directory. Consequently, the app would simply initialize the database (created lazily in AppDelegate) and this database would be empty. It would then proceed to import the 874 questions.
Check
- the bundle includes the correct version of the database file to copied
- the code that does the copying of this file.
BTW, if the data model has not changed and the game does not modify the database you might want to consider shipping a new complete database file rather then updating the old one by importing from the text file.
Cheers,
Sascha
精彩评论