views:

484

answers:

2

I'm currently working on a game for the iphone, where images are loaded from the internet and then stored in the local database so they do not have to be loaded again. This has always worked fine. Recently I created a new adhoc distribution for the testing group (the first time I created the distribution using SDK 3.1.2) and now everybody that has upgraded their iphone to 3.1.2 are no longer able to write to the database anymore, and thus have to load the images everytime from the internet. People with an iphone version lower than 3.1.2 have no problems and previously build versions (with SDK 3.1 or lower) have no problems on iphones with 3.1.2. The updates I made to the game had nothing to do with the datamanager in the game. Another strange thing is that I do not find any messages in the console using the following code:

- (void) saveImage:(NSString *)imagePath withData:(NSData *)imageData {
    if (insert_image_statement == nil){
     const char *sql2 = "INSERT INTO image (imagePath, imageData) VALUES (?, ?);";
     if (sqlite3_prepare_v2(database, sql2, -1, &insert_image_statement, NULL) != SQLITE_OK) {
      NSLog(@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
     }
    }
    sqlite3_bind_text(insert_image_statement, 1, [imagePath UTF8String], -1, NULL);
    sqlite3_bind_blob(insert_image_statement, 2, [imageData bytes], [imageData length], NULL);
    int success = sqlite3_step(insert_image_statement);
    if (success == SQLITE_ERROR){
     NSLog(@"Error: failed to insert statement with message '%s'.", sqlite3_errmsg(database));
    }
    sqlite3_reset(insert_image_statement);
}

So the sqlite3 does not throw an error which could point me towards the solution of this problem. Does anybody know why with SDK 3.1.2 I do not seem to have the permission to write the data to the database?

A: 

Sounds like a bug was introduced in the sqlite3 framework for 3.1.2. Your SQL statement looks a bit more advanced than usual with the bindings you are making. Is this a standard method for getting blobs in? Does a simple SQL statment work?

Is my understanding correct that the sqlite library is not bundled in your app but part of the iPhone framework?

kasuku
This is the standard way to insert a blob, but also a simple UPDATE statement does not work. And yes the sqlite library is part of iPhone framework.
Vincent Osinga
There are so many theories Vincent but we need to start troubleshooting one by one.You might have done this already but I would start with the database file:Do you have SSH access to the adhoc device documents folder? Maybe it's worth copying it to your mac and checking if it is a valid sqlite format. Maybe the database was double encrypted by the code-sign or something.Then verify all the database function results. From opening the database to the close. Dump out the all the results rather than checking for conditions. You could also verify that your main variables are not nil/null.
kasuku
A: 
Stan